Hamuko / cum

comic updater, mangafied

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Permission denied while creating zip + weird directory creation

abduct opened this issue · comments

The creation of the zip archive fails due to a permission denied error on one of the downloaded temporary files.

C:\Users\user\Desktop\manga>cum download suicide-island
==> Downloading 82 chapters
suicide-island 1
  [>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>]  36/36  100%
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python35-32\Scripts\cum-script.py", line 9, in <module>
    load_entry_point('cum==0.5.1.post4', 'console_scripts', 'cum')()
  File "c:\users\user\appdata\local\programs\python\python35-32\lib\site-packages\click\core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\user\appdata\local\programs\python\python35-32\lib\site-packages\click\core.py", line 696, in main
    rv = self.invoke(ctx)
  File "c:\users\user\appdata\local\programs\python\python35-32\lib\site-packages\click\core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\user\appdata\local\programs\python\python35-32\lib\site-packages\click\core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\user\appdata\local\programs\python\python35-32\lib\site-packages\click\core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "c:\users\user\appdata\local\programs\python\python35-32\lib\site-packages\cum\cum.py", line 15, in wrapper
    return f(*args, **kwargs)
  File "c:\users\user\appdata\local\programs\python\python35-32\lib\site-packages\cum\cum.py", line 164, in download
    chapter.get()
  File "c:\users\user\appdata\local\programs\python\python35-32\lib\site-packages\cum\scrapers\base.py", line 239, in get
    self.download()
  File "c:\users\user\appdata\local\programs\python\python35-32\lib\site-packages\cum\scrapers\batoto.py", line 154, in download
    self.create_zip(files)
  File "c:\users\user\appdata\local\programs\python\python35-32\lib\site-packages\cum\scrapers\base.py", line 153, in create_zip
    z.write(f.name, 'img{num:0>6}{ext}'.format(num=num, ext=ext))
  File "c:\users\user\appdata\local\programs\python\python35-32\lib\zipfile.py", line 1479, in write
    with open(filename, "rb") as fp:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\user\\AppData\\Local\\Temp\\tmp6v7_kcsm.jpe'

Due note that the temp file name is not a typo, I've seen three seperate file extensions in multiple runs of this trace back. "jpg", "jpeg", "jpe"

Secondly Inside the download_directory cum creates another directory using the download_directory sans slashes as the file name:

C:\Users\user\Desktop\manga>cum config get download_directory
download_directory = C:\Users\user\Desktop\manga

http://i.imgur.com/KQtCYsC.png

This was encountered on the latest microsoft-sucks branch.

Secondly Inside the download_directory cum creates another directory using the download_directory sans slashes as the file name:

Does that happen if you use \\ instead of \?

Does that happen if you use \ instead of ?

Yes the same traceback, and directory creation happens if I specify a file path with two backslashes via the config command.

The value returned from my original post is as follows in the config:

"download_directory": "C:\\Users\\user\\Desktop\\manga",

If I manually remove the double backslashes from the config, I get a JSON decoder traceback which is expected since backslashes need to escaped.

Although If I set the path using forward slashes via

cum config set download_directory C:/Users/user/Desktop/manga

The config becomes:

"download_directory": "C:/Users/user/Desktop/manga",

Resulting with the entire path becoming a folder. Such as the tree structure would be:

C:\Users\user\Desktop\manga\C\Users\user\Desktop\manga\Suicide Island\Suicide Island - c001 [Illuminati-Manga].zip

I added a couple of fixes that should hopefully solve these issues on Windows. At least they seemed to work fine on my Windows 10 Edu virtual machine.

I did not just push completely broken code. Pay no attention to any sort of rebasing or force pushing.

Danke, downloading and saving content to an external directory is now working with the latest push. Issue is resolved.