Skip to content

Commit

Permalink
Merge pull request #178 from haiwen/fileprovider_open_crash
Browse files Browse the repository at this point in the history
Fileprovider open crash
  • Loading branch information
freeplant authored Aug 31, 2017
2 parents 096d68d + 282b9cf commit 8ca1507
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Pod/Classes/SeafConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ - (BOOL)shouldLocalDecrypt:(NSString * _Nonnull)repoId
{
SeafRepo *repo = [self getRepo:repoId];
//Debug("Repo %@ encrypted %d version:%d, magic:%@", repoId, repo.encrypted, repo.encVersion, repo.magic);
return [self localDecrypt] && repo.encrypted && repo.encVersion >= 2 && repo.magic;
return [self localDecrypt] && repo.encrypted;
}

- (void)clearUploadCache
Expand Down
37 changes: 21 additions & 16 deletions seafile/SeafAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,39 +134,43 @@ - (BOOL)openSeafileURL:(NSURL*)url
return true;
}

- (void)uploadFile:(NSString *)path
{
[[self masterNavController:TABBED_SEAFILE] popToRootViewControllerAnimated:NO];
SeafUploadFile *file = [SeafGlobal.sharedObject.connection getUploadfile:path];
[self.fileVC uploadFile:file];
}

- (BOOL)openFileURL:(NSURL*)url
{
Debug("open %@", url);
NSString *uploadDir = [SeafGlobal.sharedObject.connection uniqueUploadDir];
NSURL *to = [NSURL fileURLWithPath:[uploadDir stringByAppendingPathComponent:url.lastPathComponent]];
Debug("Copy %@, to %@, %@, %@\n", url, to, to.absoluteString, to.path);
BOOL ret = [Utils checkMakeDir:uploadDir];
if (!ret) return false;
ret = [Utils copyFile:url to:to];
if (!ret) return false;
if (self.window.rootViewController == self.startNav) {
[self.startVC selectDefaultAccount:^(bool success) {
Debug("enter default account: %d", success);
if (success) {
[self uploadFile:to.path];
[self handleUploadPathWithUrl:url];
} else {
NSString *title = NSLocalizedString(@"Failed to upload file", @"Seafile");
[Utils alertWithTitle:title message:nil handler:nil from:self.startVC];
}
}];
} else
[self uploadFile:to.path];
[self handleUploadPathWithUrl:url];

return true;
}

- (void)handleUploadPathWithUrl:(NSURL*)url {
NSString *uploadDir = [[SeafGlobal sharedObject].connection uniqueUploadDir];
NSURL *to = [NSURL fileURLWithPath:[uploadDir stringByAppendingPathComponent:url.lastPathComponent]];
BOOL ret = [Utils checkMakeDir:uploadDir];
if (!ret) return;
ret = [Utils copyFile:url to:to];
if (ret) {
[self uploadFile:to.path];
}
}

- (void)uploadFile:(NSString *)path
{
[[self masterNavController:TABBED_SEAFILE] popToRootViewControllerAnimated:NO];
SeafUploadFile *file = [SeafGlobal.sharedObject.connection getUploadfile:path];
[self.fileVC uploadFile:file];
}

- (BOOL)openURL:(NSURL*)url
{
if (!url) return false;
Expand All @@ -179,6 +183,7 @@ - (BOOL)openURL:(NSURL*)url
Warning("Unknown scheme %@", url);
return false;
}

- (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url
{
Debug("handleOpenURL: %@", url);
Expand Down

0 comments on commit 8ca1507

Please sign in to comment.