When hardlink fails fallback to full copy
This commit is contained in:
parent
ce68e96582
commit
57a94d132f
1 changed files with 9 additions and 5 deletions
|
|
@ -4599,10 +4599,12 @@ - (void)promised_data_ready:(const char*)path sz:(size_t)sz type:(int)type {
|
|||
NSURL *srcURL = [NSURL fileURLWithPath:@(path)];
|
||||
switch (type) {
|
||||
case 0:
|
||||
// Create a hard link to path at file_url
|
||||
// Create a hard link to path at file_url or fallback to full copy
|
||||
if (![fileManager linkItemAtURL:srcURL toURL:file_url error:&error]) {
|
||||
[self end_transfer_with_error:error];
|
||||
return;
|
||||
if (![fileManager copyItemAtURL:srcURL toURL:file_url error:&error]) {
|
||||
[self end_transfer_with_error:error];
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1: {
|
||||
|
|
@ -4667,8 +4669,10 @@ - (void)promised_data_ready:(const char*)path sz:(size_t)sz type:(int)type {
|
|||
}
|
||||
} else {
|
||||
if (![fileManager linkItemAtURL:itemURL toURL:destURL error:&error]) {
|
||||
[self end_transfer_with_error:error];
|
||||
return;
|
||||
if (![fileManager copyItemAtURL:itemURL toURL:destURL error:&error]) {
|
||||
[self end_transfer_with_error:error];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue