From 1394ec56e68f7af95eb8a6c5aa26a7172e46cd8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B5ivo=20Leedj=C3=A4rv?= Date: Tue, 9 Apr 2024 20:50:57 +0200 Subject: [PATCH 1/2] Change props of the temporary file for diffing For purposes of running a local diff, a remote file is copied by the same routines that are used fo the actual sync. This includes all checks and verifications. Using "safe" dummy props (as is currently done) to copy the remote file into a temporary file can in some cases trip those checks. This mainly happens when permissions are influenced by fs/storage setup or ACL inheritance, for example. This patch sets the temporary file props to be the same as what the local file already has. The hope is that setting these props would succeed during a normal sync, so it should also work for the temporary file. --- src/files.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/files.ml b/src/files.ml index c12ed6657..44d9cfb70 100644 --- a/src/files.ml +++ b/src/files.ml @@ -847,7 +847,7 @@ let rec diff root1 path1 ui1 root2 path2 ui2 showDiff id = Lwt_unix.run (Update.translatePath root2 path2 >>= (fun path2 -> Copy.file root2 path2 root1 workingDir tmppath realPath - `Copy (Props.setLength Props.fileSafe (Props.length desc2)) + `Copy (Props.setLength desc1 (Props.length desc2)) fp2 None ress2 id) >>= fun info -> Lwt.return ()); displayDiff @@ -866,7 +866,7 @@ let rec diff root1 path1 ui1 root2 path2 ui2 showDiff id = (Update.translatePath root1 path1 >>= (fun path1 -> (* Note that we don't need the resource fork *) Copy.file root1 path1 root2 workingDir tmppath realPath - `Copy (Props.setLength Props.fileSafe (Props.length desc1)) + `Copy (Props.setLength desc2 (Props.length desc1)) fp1 None ress1 id >>= fun info -> Lwt.return ())); displayDiff From 1eae343edad14814dea5c80330143df281144649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B5ivo=20Leedj=C3=A4rv?= Date: Tue, 9 Apr 2024 21:06:30 +0200 Subject: [PATCH 2/2] Use proper temp names for diff temp files The previous patches (almost 20 years ago) intending to do this didn't quite finish the job. The added bonus with proper temp names is that they will be included in the automatic cleanup, should they be left behind for some reason. --- src/files.ml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/files.ml b/src/files.ml index 44d9cfb70..b321e1ff7 100644 --- a/src/files.ml +++ b/src/files.ml @@ -841,8 +841,8 @@ let rec diff root1 path1 ui1 root2 path2 ui2 showDiff id = (fun () -> let path1 = Update.translatePathLocal fspath1 path1 in let (workingDir, realPath) = Fspath.findWorkingDir fspath1 path1 in - let tmppath = - Path.addSuffixToFinalName realPath (tempName "diff-") in + let tmppath = Os.tempPath ~fresh:false workingDir + (Path.addSuffixToFinalName realPath "-diff") in Os.delete workingDir tmppath; Lwt_unix.run (Update.translatePath root2 path2 >>= (fun path2 -> @@ -860,8 +860,8 @@ let rec diff root1 path1 ui1 root2 path2 ui2 showDiff id = (fun () -> let path2 = Update.translatePathLocal fspath2 path2 in let (workingDir, realPath) = Fspath.findWorkingDir fspath2 path2 in - let tmppath = - Path.addSuffixToFinalName realPath "#unisondiff-" in + let tmppath = Os.tempPath ~fresh:false workingDir + (Path.addSuffixToFinalName realPath "-diff") in Lwt_unix.run (Update.translatePath root1 path1 >>= (fun path1 -> (* Note that we don't need the resource fork *)