Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YaDisk.Upload() not actaully apply argument "overwrite" #33

Closed
starostin13 opened this issue Oct 27, 2023 · 1 comment
Closed

YaDisk.Upload() not actaully apply argument "overwrite" #33

starostin13 opened this issue Oct 27, 2023 · 1 comment
Labels

Comments

@starostin13
Copy link

Steps to reproduce

  1. Create folder inside Yandex Disk (yandexFolder)
  2. prepare file (image for example)
  3. call method YaDisk.upload(localpath, yandexFolder, overwrite=True)
    Actual behaviour:
    Exception raised:
    Message=По указанному пути "disk:/Изображения/SanochkiInteractive/Test Folder" уже существует папка с таким именем. (Specified path "disk:/Изображения/SanochkiInteractive/Test Folder" points to existent directory. / DiskPathPointsToExistentDirectoryError)
    Source=C:\Users\al-gerasimov\source\repos\Chronica\yaHelper.py
    StackTrace:
    File "C:\Users\al-gerasimov\source\repos\Chronica\yaHelper.py", line 51, in saveFileTo
    y.upload(localpath, credentials.main_dirrectory + "/" + yandexFolder, overwrite=TRUE)
    File "C:\Users\al-gerasimov\source\repos\Chronica\bot.py", line 25, in callback_query (Current frame)
    saveFileTo(os.path.join(dst, entry), call.data)
    yadisk.exceptions.DirectoryExistsError: По указанному пути "disk:/Изображения/SanochkiInteractive/Test Folder" уже существует папка с таким именем. (Specified path "disk:/Изображения/SanochkiInteractive/Test Folder" points to existent directory. / DiskPathPointsToExistentDirectoryError)

Expected:
Now exceptions and file was uploaded to existed folder in Yandex Disk

Also, repository haven't test cases cover such cases.

If owner haven't resources for fix issue, I'll start work on it soon.

Thanks

@ivknv
Copy link
Owner

ivknv commented Oct 27, 2023

The overwrite parameter is not ignored, it's just that you can't overwrite folders.

This isn't really a bug, this is just how the Yandex.Disk's REST API works. Getting an error in this case makes perfect sense. You are supposed to provide the full destination path, not just the parent folder.

Expected:
No exceptions and file was uploaded to existing folder in Yandex Disk

Introducing the suggested behavior would only make the method less consistent and could lead to silent accidents (e.g. accidentally uploading into a folder instead of overwriting what was assumed to be a file).

@ivknv ivknv added bug Suspected or confirmed bug language-english Issue in English wontfix and removed bug Suspected or confirmed bug labels Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants