Skip to content

Commit

Permalink
[App] If opening a file in-place, we need to copy, not move it
Browse files Browse the repository at this point in the history
  • Loading branch information
kirb committed Dec 19, 2022
1 parent 19d2b49 commit 3f2eda0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Zebra/ZBAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,13 @@ - (BOOL)application:(UIApplication *)application openURL:(nonnull NSURL *)url op
NSString *newLocation = [[[self class] debsLocation] stringByAppendingPathComponent:[url lastPathComponent]];

NSError *moveError;
[[NSFileManager defaultManager] moveItemAtPath:[url path] toPath:newLocation error:&moveError];
if ([options[UIApplicationOpenURLOptionsOpenInPlaceKey] boolValue]) {
// File is owned by another app. Make a copy.
[[NSFileManager defaultManager] copyItemAtPath:[url path] toPath:newLocation error:&moveError];
} else {
// File is in our inbox. Move it.
[[NSFileManager defaultManager] moveItemAtPath:[url path] toPath:newLocation error:&moveError];
}
if (moveError) {
NSLog(@"[Zebra] Couldn't move deb %@", moveError.localizedDescription);
}
Expand Down

0 comments on commit 3f2eda0

Please sign in to comment.