odwyersoftware / mega.py

Python library for the https://mega.nz/ API.
https://github.com/odwyersoftware/mega.py
Apache License 2.0
349 stars 170 forks source link

delete_url deletes one folder instead of the linked file #73

Open ZuriPL opened 2 years ago

ZuriPL commented 2 years ago

I'm trying to write a script to sync one of the folders one my pc to a folder in MEGA

My idea was to to write a loop which deletes a certain file in MEGA and upload a new one (both have the same name). I have been struggling with the deleting part though. Here's a part of my code (that matters)

`j = 0

for i in pathlib.Path(output).iterdir(): m.delete_url(m.get_link(m.find(get_filename(output, j)))) m.upload(i, cloud_dest[0]) j += 1`

the get_filename() function i have in my other library file, but I did some debug prints which show it works (if i print m.get_link(m.find(get_filename(output, j))) it succesfully returns me the link to the correct file. So, since i input the correct link to the delete_url function, I cannot understand why the function moves to trash one directory from my root MEGA share, instead of the file I ask it to. Abd sunce I have more files than folders, the script crashes midway, with this error:

Traceback (most recent call last): File "c:\Users\micha\Documents\VSCode\sync.py", line 28, in <module> m.delete_url(m.get_link(m.find(get_filename(output, j)))) File "C:\Users\micha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\mega\mega.py", line 528, in delete_url return self.move(file_id, 4) File "C:\Users\micha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\mega\mega.py", line 946, in move return self._api_request({ File "C:\Users\micha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tenacity\__init__.py", line 293, in wrapped_f return self.call(f, *args, **kw) File "C:\Users\micha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tenacity\__init__.py", line 359, in call do = self.iter(retry_state=retry_state) File "C:\Users\micha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tenacity\__init__.py", line 320, in iter return fut.result() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\concurrent\futures\_base.py", line 438, in result return self.__get_result() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\concurrent\futures\_base.py", line 390, in __get_result raise self._exception File "C:\Users\micha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tenacity\__init__.py", line 362, in call result = fn(*args, **kwargs) File "C:\Users\micha\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\mega\mega.py", line 188, in _api_request raise RequestError(int_resp) mega.errors.RequestError: EACCESS, Access violation (e.g., trying to write to a read-only share)

What's the issue here? Maybe I'm doing something wrong?

arihantai commented 2 years ago

Same issue for me!