organize icon indicating copy to clipboard operation
organize copied to clipboard

Moving a file to a NAS server triggers an error

Open robolth opened this issue 1 year ago • 10 comments
trafficstars

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 avatar Mar 23 '24 18:03 robolth

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 ?

nodecentral avatar Mar 25 '24 07:03 nodecentral

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.

robolth avatar Mar 29 '24 08:03 robolth

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?

tfeldmann avatar Mar 29 '24 14:03 tfeldmann

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.

robolth avatar Mar 29 '24 22:03 robolth

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.

tfeldmann avatar Apr 04 '24 16:04 tfeldmann

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

robolth avatar Apr 06 '24 17:04 robolth

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

tfeldmann avatar Apr 06 '24 18:04 tfeldmann

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?

robolth avatar Apr 14 '24 11:04 robolth

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?

tfeldmann avatar Apr 14 '24 14:04 tfeldmann

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

robolth avatar Apr 14 '24 19:04 robolth