C0D3D3V / Moodle-DL

Moodle-DL downloads course content fast from Moodle (eg. lecture pdfs)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FileNotFoundError: [Errno 2] No such file or directory:

milousparks opened this issue · comments

Bug:

Some files won't download from courses.
This seems to be independent of the file type.
Already tried to execute with elevated rights.

2022-05-02 12:56:18 ERROR {url_target} T2 - Failed seting up target file: "M9 Digitale Signalverarbeitung (SL) - 1. Zug- SoSe2022\Vorlesungsfolien aus dem SoSe2021 (nicht zur Prüfungsvorbereitung verwenden)\SE08 Eigenschaften der Fouriertransformation.pdf" 2022-05-02 12:56:18 ERROR {url_target} T2 - Error while trying to download file: URLTarget (File (module_id: 1140869, section_name: "Vorlesungsfolien aus dem SoSe2021 (nicht zur Prüfungsvorbereitung verwenden)", section_id: "344309", module_name: "SE08 Eigenschaften der Fouriertransformation", content_filepath: /, content_filename: "SE08 Eigenschaften der Fouriertransformation.pdf", content_fileurl: "https://moodle.htw-berlin.de/webservice/pluginfile.php/1421180/mod_resource/content/1/SE08%20Eigenschaften%20der%20Fouriertransformation.pdf?forcedownload=1", content_filesize: 688746, content_timemodified: 1591706315, module_modname: resource, content_type: file, content_isexternalfile: False, saved_to: "M9 Digitale Signalverarbeitung (SL) - 1. Zug- SoSe2022\Vorlesungsfolien aus dem SoSe2021 (nicht zur Prüfungsvorbereitung verwenden)\SE08 Eigenschaften der Fouriertransformation.pdf", time_stamp: 0, modified: False, moved: False, deleted: False, notified: False, hash: None, file_id: None, old_file_id: None), Course (id: 36403, fullname: "M9 Digitale Signalverarbeitung (SL) - 1. Zug- SoSe2022", overwrite_name_with: "None", create_directory_structure: True, files: 31), False, Error: [Errno 2] No such file or directory: 'M9 Digitale Signalverarbeitung (SL) - 1. Zug- SoSe2022\\Vorlesungsfolien aus dem SoSe2021 (nicht zur Prüfungsvorbereitung verwenden)\\SE08 Eigenschaften der Fouriertransformation.pdf') 2022-05-02 12:56:18 ERROR {url_target} T2 - Traceback: Traceback (most recent call last): File "C:\Users\milan\AppData\Local\Programs\Python\Python310\lib\site-packages\moodle_dl\download_service\url_target.py", line 844, in download self.set_path() File "C:\Users\milan\AppData\Local\Programs\Python\Python310\lib\site-packages\moodle_dl\download_service\url_target.py", line 696, in set_path self.file.saved_to = self._rename_if_exists(self.file.saved_to) File "C:\Users\milan\AppData\Local\Programs\Python\Python310\lib\site-packages\moodle_dl\download_service\url_target.py", line 166, in _rename_if_exists raise e File "C:\Users\milan\AppData\Local\Programs\Python\Python310\lib\site-packages\moodle_dl\download_service\url_target.py", line 162, in _rename_if_exists open(new_path, 'a', encoding='utf-8').close() FileNotFoundError: [Errno 2] No such file or directory: 'M9 Digitale Signalverarbeitung (SL) - 1. Zug- SoSe2022\\Vorlesungsfolien aus dem SoSe2021 (nicht zur Prüfungsvorbereitung verwenden)\\SE08 Eigenschaften der Fouriertransformation.pdf'

do you have Windows 10 or later?
I think you do not have long path enabled, see
https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd

just run New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force as administrator in powershell or use my option moodle-dl --max-path-length-workaround if you do not want to enable long path

Damn i did know this was an issue, and suspected it also in this case but i did not know you can increase the max file path length.
This fixes more problems than you can imagine.

I can confirm that your suggestion fixes the problem, thank you.