hydrus icon indicating copy to clipboard operation
hydrus copied to clipboard

MacOS File Permissions Error when Exporting

Open KamillaPup opened this issue 2 years ago • 5 comments

Hydrus version

512

Qt major version

Qt 6

Operating system

macOS 12 "Monterey" (Apple silicon)

Install method

Installer

Install and OS comments

No response

Bug description and reproduction

CleanShot 2023-01-12 at 12 13 52

When exporting files to my home folder, it keeps telling me PermissionError, Operation not permitted. This is weird as the files are being exported just fine so not sure why it's crying.

Log output

No response

KamillaPup avatar Jan 12 '23 18:01 KamillaPup

I have never had this issue across multiple versions of macOS including the one you're using. I'm curious, have you tried using a different path? I always export to a specific folder outside of Pictures, namely, ~/hydrus_export. If you try other paths and it doesn't work still, then I'll be out of ideas, but hopefully someone else will be able to assist you.

roachcord3 avatar Jan 12 '23 19:01 roachcord3

Using v519 now.

Important Update! My database files (not thumbs) are located on an SMB share. So I am copying them across the SMB share to a locally attached USB drive. But it also does this when copying to my main boot drive.

So I tried this again with an external drive formatted with exFat so no permissions and it still gives it despite Hydrus Network having full disk access. Here is the full trace back:

PermissionError
[Errno 1] Operation not permitted: '/Volumes/Wolf/red-wolf-hydrus/z00p/149645.jpg'
Traceback (most recent call last):
  File "/Applications/Hydrus Network.app/Contents/MacOS/hydrus/core/HydrusPaths.py", line 649, in MirrorFile
    safe_copy2( source, dest )
  File "/Applications/Hydrus Network.app/Contents/MacOS/hydrus/core/HydrusPaths.py", line 530, in safe_copy2
    shutil.copy2( source, dest )
  File "shutil", line 445, in copy2
    copystat(src, dst, follow_symlinks=follow_symlinks)
  File "shutil", line 405, in copystat
    lookup("chflags")(dst, st.st_flags, follow_symlinks=follow)
PermissionError: [Errno 1] Operation not permitted: '/Volumes/Wolf/red-wolf-hydrus/z00p/149645.jpg'

CleanShot 2023-03-10 at 02 02 19

KamillaPup avatar Mar 10 '23 08:03 KamillaPup

So, I'm still not sure what the cause of your problem is, but, I wanted to make sure you're not doing something that causes problems, based on your comment here:

My database files (not thumbs) are located on an SMB share

I just want to be sure: you mean the actual media files, not the sqlite databases, right? There are known issues with sqlite over network shares that range from "doesn't work at all" to "looks like it's working but will corrupt your data pretty quickly." If you are putting your sqlite dbs on an SMB share, stop that right now before something really bad happens!

But, again, I'm not sure what the solution to your problem here is. You said you gave Hydrus full disk access, so I would assume that it should just work. The only thing I can suggest is that you try debugging by seeing if you can do cp /Volumes/home/Hydrus/client_files/.../.............jpg /Volumes/Wolf/red-wolf-hydrus/z00p/.....jpg (obviously replace the dots with the actual paths.) If you can do that but Hydrus can't, then I can only assume that Hydrus does not actually have disk access in the security settings. (Maybe check to see if it's appearing to the OS as python and not Hydrus, as that's what it appears as to me, but I run from source so...)

roachcord3 avatar Mar 11 '23 02:03 roachcord3

Thanks for the reply! No, the db files are all stored on the boot drive in the default location along with the thumbs. CleanShot 2023-03-10 at 21 26 05 I made sure to grant the app full disk access. CleanShot 2023-03-10 at 21 20 11 The cp command works fine with no errors. Mac-Studio ~ % cp /Volumes/home/Hydrus/client_files/f8b/8b0c34dcf50b4aa20d6156136d20dee479fe0f0153d18347a07179dcd074194a.jpg /Volumes/Wolf/red-wolf-hydrus/z00p

KamillaPup avatar Mar 11 '23 03:03 KamillaPup

@KamillaPup This error while annoying is safe to ignore based on your description. Hydrus is using shutil.copy2(), which attempts to preserve any file attributes. It is failing when attempting to copy flags from the source to the target. It is failing for one of the following reasons

Failure modes of chflags()

[EPERM] The effective user ID does not match the owner of the file and the effective user ID is not the super-user. [EPERM] One of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK is set and the user is either not the super-user or securelevel is greater than 0. [EPERM] A non-super-user attempted to toggle one of SF_ARCHIVED, SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK. [EPERM] An attempt was made to toggle the SF_SNAPSHOT flag. https://manpages.debian.org/bullseye/freebsd-manpages/chflags.2freebsd.en.html

bbappserver avatar Apr 13 '23 09:04 bbappserver