Revision: 16733
          http://sourceforge.net/p/skim-app/code/16733
Author:   hofman
Date:     2026-10-28 15:28:49 +0000 (Wed, 28 Oct 2026)
Log Message:
-----------
update stale bookmark alias when matching fileURL

Modified Paths:
--------------
    trunk/SKAlias.m

Modified: trunk/SKAlias.m
===================================================================
--- trunk/SKAlias.m     2026-10-28 10:29:29 UTC (rev 16732)
+++ trunk/SKAlias.m     2026-10-28 15:28:49 UTC (rev 16733)
@@ -136,6 +136,15 @@
     return aliasHandle == nil && data != nil;
 }
 
+- (void)updateWithURL:(NSURL *)fileURL {
+    NSData *bmData = [fileURL bookmarkDataWithOptions:0 
includingResourceValuesForKeys:nil relativeToURL:nil error:NULL];
+    if (bmData) {
+        if (aliasHandle)
+            disposeAliasHandle(aliasHandle);
+        data = bmData;
+    }
+}
+
 - (NSURL *)fileURLAllowingUI:(BOOL)allowUI {
     // we could cache the fileURL, but it would break when moving the file 
while we run
     NSURL *fileURL = nil;
@@ -157,14 +166,8 @@
             fileURL = [NSURL URLByResolvingBookmarkData:data options:options 
relativeToURL:nil bookmarkDataIsStale:&shouldUpdate error:NULL];
         }
     }
-    if (shouldUpdate && fileURL) {
-        NSData *bmData = [fileURL bookmarkDataWithOptions:0 
includingResourceValuesForKeys:nil relativeToURL:nil error:NULL];
-        if (bmData) {
-            if (aliasHandle)
-                disposeAliasHandle(aliasHandle);
-            data = bmData;
-        }
-    }
+    if (shouldUpdate && fileURL)
+        [self updateWithURL:fileURL];
     return fileURL;
 }
 
@@ -185,19 +188,30 @@
         NSString *path = [dict objectForKey:NSURLPathKey];
         NSString *myPath = [myDict objectForKey:NSURLPathKey];
         if (path && myPath) {
-            if ([path isCaseInsensitiveEqual:myPath])
+            NSNumber *fileID = [dict objectForKey:NSURLFileIDKey];
+            NSNumber *myFileID = [myDict objectForKey:NSURLFileIDKey];
+            if ([path isCaseInsensitiveEqual:myPath]) {
+                if (fileID && myFileID && [fileID isEqual:myFileID] == NO)
+                    [self updateWithURL:fileURL];
                 return YES;
-            if ([[NSURL fileURLWithPath:myPath isDirectory:[[myPath 
pathExtension] isCaseInsensitiveEqual:@"pdfd"]] 
checkResourceIsReachableAndReturnError:NULL])
+            }
+            NSURL *myFileURL = [NSURL fileURLWithPath:myPath 
isDirectory:[[myPath pathExtension] isCaseInsensitiveEqual:@"pdfd"]];
+            if ([myFileURL checkResourceIsReachableAndReturnError:NULL]) {
+                if (fileID && myFileID && [fileID isEqual:myFileID] == NO)
+                    [self updateWithURL:myFileURL];
                 return NO;
-            NSNumber *fileID = [dict objectForKey:NSURLFileIDKey];
-            NSNumber *myFileID = [myDict objectForKey:NSURLFileIDKey];
+            }
             if (fileID && myFileID) {
                 if ([fileID isEqual:myFileID] == NO)
                     return NO;
                 NSString *volumeID = [dict 
objectForKey:NSURLVolumeIdentifierKey];
                 NSString *myVolumeID = [myDict 
objectForKey:NSURLVolumeIdentifierKey];
-                if (volumeID && myVolumeID)
-                    return [volumeID isEqualToString:myVolumeID];
+                if ([volumeID isEqualToString:myVolumeID]) {
+                    [self updateWithURL:fileURL];
+                    return YES;
+                } else if (volumeID && myVolumeID) {
+                    return NO;
+                }
             }
         }
         NSURLBookmarkResolutionOptions options = 
NSURLBookmarkResolutionWithoutUI | NSURLBookmarkResolutionWithoutMounting;

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to