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

Deleted empty folders do not sync between the initiator and target #264

Open
Julpro21 opened this issue Apr 29, 2024 · 9 comments
Open

Deleted empty folders do not sync between the initiator and target #264

Julpro21 opened this issue Apr 29, 2024 · 9 comments

Comments

@Julpro21
Copy link

Empty folders can by sync between the initiator and target. However, when I delete some of them, say, inside the initiator folder, the deletion does not reflect to the target folder. In fact, it breaks the whole synchronization.
I got this message:

cp: /Users//Desktop/B/A is a directory (not copied).
TIME: 1 - \e[91mCannot move [/Users/
/Desktop/B/A] to deletion directory [/Users/*/Desktop/B/.osync_workdir/deleted] on target.\e[0m
TIME: 1 - \e[1;33;41mDeletion on target replica failed.\e[0m
TIME: 1 - \e[91m_ExecTasksPidsCheck called by [Sync_deletionPropagation] finished monitoring pid [6841] with exitcode [1].\e[0m
TIME: 1 - \e[91mosync finished with errors.\e[0m

Please note that this behavior disappears and everything works correctly if I set: SOFT_DELETE=false. Also, I'm using a Macbook Pro with Sonoma installed.

@Julpro21 Julpro21 changed the title Deleted empty folders do not sync between initiator and target Deleted empty folders do not sync between the initiator and target Apr 29, 2024
@deajan
Copy link
Owner

deajan commented Apr 29, 2024

I'd really need a reproducible example, eg folder tree before deletion, folder tree after sync, full error message, osync version.
With this, I'm pretty sure that I could make a quick fix.

@Julpro21
Copy link
Author

Julpro21 commented Apr 29, 2024

Thank you for your reply. Here is a reproducible example:

Create two folders inside the initiator folder (called initiator_folder). One subfolder is not empty (subfolder_1) and the other one is empty (subfolder_2):

mkdir -p "$HOME/Desktop/initiator_folder/subfolder_1"
touch "$HOME/Desktop/initiator_folder/subfolder_1/example.txt"
mkdir -p "$HOME/Desktop/initiator_folder/subfolder_2"

Now create the target folder (target_folder):

mkdir -p "$HOME/Desktop/target_folder"

Using osync:

bash osync.sh --initiator="$HOME/Desktop/initiator_folder" --target="$HOME/Desktop/target_folder"

So far so good. But now let's remove the empty subfolder and run osync again. Please note that if we remove the non empty folder, it will work with no errors. The problem is with the empty folders.

rm -rf "$HOME/Desktop/initiator_folder/subfolder_2"
bash osync.sh --initiator="$HOME/Desktop/initiator_folder" --target="$HOME/Desktop/target_folder"

The following error message will appear:

cp: /Users/xx/Desktop/target_folder/subfolder_2 is a directory (not copied).
TIME: 0 - \e[91mCannot move [/Users/xx/Desktop/target_folder/subfolder_2] to deletion directory [/Users/xx/Desktop/target_folder/.osync_workdir/deleted] on target.\e[0m
TIME: 0 - \e[1;33;41mDeletion on target replica failed.\e[0m
TIME: 0 - \e[91m_ExecTasksPidsCheck called by [Sync_deletionPropagation] finished monitoring pid [17506] with exitcode [1].\e[0m
TIME: 1 - \e[91mosync finished with errors.\e[0m

I believe that this is mainly because of (rm -f and cp -p) when used with folders. On macOS, you need the "r" option for recursive with folders. So, we should use (rm -rf, and cp -rp or cp -Rp).

Finally, I just saw this similar discussions here: #254

@deajan
Copy link
Owner

deajan commented Apr 29, 2024

So you're running osync 1.3-rtm on MacOS which version ?

I'd be thrilled to test your "-r" reasoning, but I dont have any macs :(
Mind to mod osync.sh with your suggestion and report back ?
I'll happily make a release.

@Julpro21
Copy link
Author

I'm running osync-1.3 with macOS Sonoma (14.4.1).

@Julpro21
Copy link
Author

I did the following and it works perfectly now:
sed -i '' 's/cp -p/cp -pR/g' "./osync.sh"
sed -i '' 's/rm -f/rm -rf/g' "./osync.sh"

@Julpro21
Copy link
Author

Please have a look at: #254

@deajan
Copy link
Owner

deajan commented Apr 29, 2024

That's a bit broad ;)
I'll see whether those changes will work with the unit tests. If so, I'll make a release.
You may make a PR (on n_osync.sh) if you wish to be mentionned.

Thank you for your diag ;)

@Julpro21
Copy link
Author

Thank you for your help. I'm not sure if I should mention this here, but the following typos are in the osync.sh file.

"# Leave the possibity to set SLEEP_TIME as environment variable when runinng with bash -x in order to avoid spamming console"

possibity should be possibility
runinng should be running

Thanks again

@deajan
Copy link
Owner

deajan commented Apr 29, 2024

Sure. I'll have them sorted. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants