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

Moving a file to a NAS server triggers an error #373

Open
robolth opened this issue Mar 23, 2024 · 10 comments
Open

Moving a file to a NAS server triggers an error #373

robolth opened this issue Mar 23, 2024 · 10 comments
Labels

Comments

@robolth
Copy link

robolth commented Mar 23, 2024

Moving a file to a NAS Server triggers an error. The file is copied, but the original is not removed.
This did not happen with v2.
I believe this is the same issue as in this SO thread: https://stackoverflow.com/questions/18621577/errno-22-with-python-shutil-and-move-function

Output of organize run:

Rule #0: Move file to NAS volume
 ──────────
/Users/user/Downloads/file.txt
    - (move) Move to /Volumes/NAS-volume/file.txt
    - (move) ERROR! [('/Users/user/Downloads/file.txt', '/Volumes/NAS-volume/file.txt', "[Errno 22] 
Invalid argument: '/Volumes/NAS-volume/file.txt'")]

Please note that the file has been copied to the NAS volume despite the error. The original, however, has not been removed.

  • OS: macOS Sonoma 14.4
  • Output of organize --version: organize v3.2.2

Your config file

rules:
  - name: "Move file to NAS volume"
    locations: "/Users/user/Downloads/"
    subfolders: false
    filters:
      - extension: txt
    actions:
      - move:
          dest: "/Volumes/NAS-volume/"
          on_conflict: "skip"
@robolth robolth added the bug label Mar 23, 2024
@nodecentral
Copy link

nodecentral commented Mar 25, 2024

Hi @robolth - sorry I don’t want to hijack this thread, but I have a very similar issue, although by the looks of it I’m on v2.4 not v3 - I’m trying to move a txt from one location on a mapped volume to another. All I get is permissions errors (even though both users seem to be in the same group (1000), and both the file & directory have r-w, rwx, r-- permissions.

What user, group and permissions do you have on the elements involved in your error ?

@robolth
Copy link
Author

robolth commented Mar 29, 2024

Hi, here are the permissions of my NAS volume: drwx------
For more details: I'm on macOS 14.4.1
I did not have this issue prior to updating to organize v3.

@tfeldmann
Copy link
Owner

tfeldmann commented Mar 29, 2024

Thanks for reporting. I'm struggling reproducing this. Did you find anything strange with the paths shown (I guess '/Users/user/Downloads/file.txt', '/Volumes/NAS-volume/file.txt' are placeholders) like spaces, special characters or wrong slashes?

@robolth
Copy link
Author

robolth commented Mar 29, 2024

Thanks for investigating this. They're placeholders, you're right; however I've juste reproduced it with a tailor-made rule and txt file:

/Users/test-user
  ./file.txt
    - (move) Move to /Volumes/test-volume/file.txt
    - (move) ERROR! [Errno 22] Invalid argument: '/Volumes/test-volume/file.txt'

These are the real volume and file names and paths: only special character is -.

I don't know why there is a newline and a . in the destination folder, the real path is /Users/billet-cleanly/file.txt, however this is also the case fo the output of other rules with no issue.

Edit: as a last test, I also tried to simply move it on the Mac hard drive rather than on the NAS, this time without any issue, so it really seems to be caused by the NAS.

@tfeldmann
Copy link
Owner

Can you try moving the files manually using the following script:

import argparse
import shutil
from pathlib import Path

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("src", type=Path)
    parser.add_argument("dst", type=Path)
    parser.add_argument("--simple", action="store_true")

    args = parser.parse_args()
    src = str(args.src.resolve())
    dst = str(args.dst.resolve())

    print(f"Moving {src} to {dst}")

    if args.simple:
        shutil.move(src, dst, copy_function=shutil.copy)
    else:
        shutil.move(src, dst)

Please try both moving methods with python3 movescript.py sourcefile destfile and python3 movescript.py sourcefile destfile --simple.

Organize uses the same method of moving so that would be super helpful.

@robolth
Copy link
Author

robolth commented Apr 6, 2024

Just tried it: it works with both methods without any issue.

@tfeldmann
Copy link
Owner

That’s great! We’re getting closer. Does organize fail on symlinks or symlinked folders? It might be a missing ‘resolve‘ on the target.

@robolth
Copy link
Author

robolth commented Apr 14, 2024

I'm not sure how I can check whether this is the case. Here is a ls -l on the target folder:

user@user-computer / % ls -al /Users/user/Library/Mobile\ Documents/com~apple~CloudDocs/Downloads
total 1720
-rw-r--r--@ 1 billet-cleanly  staff  0 26 nov 18:58 Icon?

Does that help?

@tfeldmann
Copy link
Owner

Ah so the target is the iCloud Drive folder? Is it failing on both iCloud Drive and the network volume? Did you grant your terminal the permission to read iCloud in your system settings?

@robolth
Copy link
Author

robolth commented Apr 14, 2024

Yes, it's the iCloud Drive folder. It's not failing on the target iCloud Drive subfolder (since it successfully copy files from there to the network volume, and is also able to trash them afterwards). The only problem is on the actual network drive, where it can copy files but not move them.
I did check: I granted terminal permission to read iCloud on the system settings.

I might be wrong, but I believe the issue is the same as the one depicted here: https://stackoverflow.com/questions/18621577/errno-22-with-python-shutil-and-move-function

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

3 participants