Skip to content

Commit

Permalink
6.4.2-rc3 (#1163)
Browse files Browse the repository at this point in the history
- Add setting to configure if file transfers should show up in Files App
  • Loading branch information
tmolitor-stud-tu authored Jul 31, 2024
2 parents f6d2fc1 + 2e62651 commit 9cb55d5
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/beta.build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ jobs:
#run: xcrun altool --upload-app -f ./Monal/build/ipa/Monal.ipa --type ios --asc-provider S8D843U34Y --team-id S8D843U34Y -u "$(cat /Users/ci/apple_connect_upload_mail.txt)" -p "$(cat /Users/ci/apple_connect_upload_secret.txt)"
env:
PILOT_LOCALIZED_BUILD_INFO: ${{ steps.buildinfo.outputs.buildinfo_ios }}
PILOT_CHANGELOG: ${{ steps.releasenotes.outputs.notes_ios }}
run: |
fastlane run upload_to_testflight api_key_path:"/Users/ci/appstoreconnect/key.json" team_id:"S8D843U34Y" ipa:"./Monal/build/ipa/Monal.ipa" distribute_external:true groups:"Internal Pre-Beta Testers","Public Beta" reject_build_waiting_for_review:true submit_beta_review:true
- name: Notarize catalyst
Expand Down Expand Up @@ -182,6 +183,7 @@ jobs:
#run: xcrun altool --upload-app --file ./Monal/build/app/Monal.pkg --type macos --asc-provider S8D843U34Y -u "$(cat /Users/ci/apple_connect_upload_mail.txt)" -p "$(cat /Users/ci/apple_connect_upload_secret.txt)" --primary-bundle-id org.monal-im.prod.catalyst.monal
env:
PILOT_LOCALIZED_BUILD_INFO: ${{ steps.buildinfo.outputs.buildinfo_macos }}
PILOT_CHANGELOG: ${{ steps.releasenotes.outputs.notes_macos }}
run: |
fastlane run upload_to_testflight api_key_path:"/Users/ci/appstoreconnect/key.json" team_id:"S8D843U34Y" pkg:"./Monal/build/app/Monal.pkg" distribute_external:true groups:"Internal Pre-Beta Testers","Public Beta" reject_build_waiting_for_review:true submit_beta_review:true
- name: Release
Expand Down
8 changes: 7 additions & 1 deletion Monal/Classes/GeneralSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ class GeneralSettingsDefaultsDB: ObservableObject {

@defaultsDB("uploadImagesOriginal")
var uploadImagesOriginal: Bool

@defaultsDB("hardlinkFiletransfersIntoDocuments")
var hardlinkFiletransfersIntoDocuments: Bool
}


Expand Down Expand Up @@ -457,7 +460,10 @@ struct AttachmentSettings: View {
Form {
Section(header: Text("General File Transfer Settings")) {
SettingsToggle(isOn: $generalSettingsDefaultsDB.autodownloadFiletransfers) {
Text("Auto-Download Media")
Text("Auto-Download Media and Files")
}
SettingsToggle(isOn: $generalSettingsDefaultsDB.hardlinkFiletransfersIntoDocuments) {
Text("Make transfered Media and Files accessible in Files App")
}
}

Expand Down
61 changes: 32 additions & 29 deletions Monal/Classes/MLFiletransfer.m
Original file line number Diff line number Diff line change
Expand Up @@ -358,67 +358,70 @@ -(void) URLSession:(nonnull NSURLSession*) session downloadTask:(nonnull NSURLSe
if(error)
{
DDLogError(@"Could not copy cache file to tmp file: %@", error);
#ifdef DEBUG
#ifdef DEBUG
@throw [NSException exceptionWithName:@"ERROR_WHILE_COPYING_CACHEFILE" reason:@"Could not copy cacheFile!" userInfo:@{
@"cacheFile": cacheFile,
@"cacheFileTMP": cacheFileTMP
}];
#endif
#endif
return;
}

[_fileManager removeItemAtPath:cacheFile error:&error];
if(error)
{
DDLogError(@"Could not delete original cache file: %@", error);
#ifdef DEBUG
#ifdef DEBUG
@throw [NSException exceptionWithName:@"ERROR_WHILE_DELETING_CACHEFILE" reason:@"Could not delete cacheFile!" userInfo:@{
@"cacheFile": cacheFile
}];
#endif
#endif
return;
}

[_fileManager moveItemAtPath:cacheFileTMP toPath:cacheFile error:&error];
if(error)
{
DDLogError(@"Could not rename tmp file to cache file: %@", error);
#ifdef DEBUG
#ifdef DEBUG
@throw [NSException exceptionWithName:@"ERROR_WHILE_RENAMING_CACHEFILE" reason:@"Could not rename cacheFileTMP to cacheFile!" userInfo:@{
@"cacheFile": cacheFile,
@"cacheFileTMP": cacheFileTMP
}];
#endif
#endif
return;
}
}

NSURL* hardLink = [[_fileManager URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
for(NSString* pathComponent in hardlinkPathComponents)
hardLink = [hardLink URLByAppendingPathComponent:pathComponent];

DDLogInfo(@"Hardlinking cache file at '%@' into documents directory at '%@'...", cacheFile, hardLink);
if(![_fileManager fileExistsAtPath:[hardLink.URLByDeletingLastPathComponent path]])
if([[HelperTools defaultsDB] boolForKey:@"hardlinkFiletransfersIntoDocuments"])
{
DDLogVerbose(@"Creating hardlinking dir struct at '%@'...", hardLink.URLByDeletingLastPathComponent);
[_fileManager createDirectoryAtURL:hardLink.URLByDeletingLastPathComponent withIntermediateDirectories:YES attributes:@{NSFileProtectionKey: NSFileProtectionCompleteUntilFirstUserAuthentication} error:&error];
if(error)
DDLogWarn(@"Ignoring error creating hardlinking dir struct at '%@': %@", hardLink, error);
NSURL* hardLink = [[_fileManager URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
for(NSString* pathComponent in hardlinkPathComponents)
hardLink = [hardLink URLByAppendingPathComponent:pathComponent];

DDLogInfo(@"Hardlinking cache file at '%@' into documents directory at '%@'...", cacheFile, hardLink);
if(![_fileManager fileExistsAtPath:[hardLink.URLByDeletingLastPathComponent path]])
{
DDLogVerbose(@"Creating hardlinking dir struct at '%@'...", hardLink.URLByDeletingLastPathComponent);
[_fileManager createDirectoryAtURL:hardLink.URLByDeletingLastPathComponent withIntermediateDirectories:YES attributes:@{NSFileProtectionKey: NSFileProtectionCompleteUntilFirstUserAuthentication} error:&error];
if(error)
DDLogWarn(@"Ignoring error creating hardlinking dir struct at '%@': %@", hardLink, error);
else
[HelperTools configureFileProtection:NSFileProtectionCompleteUntilFirstUserAuthentication forFile:[hardLink path]];
}

//don't throw any error if the file aready exists, because it could be a rare collision (we only use 16 bit random numbers to keep the file prefix short)
if([_fileManager fileExistsAtPath:[hardLink path]])
DDLogWarn(@"Not hardlinking file '%@' to '%@': file already exists (maybe a rare collision?)...", cacheFile, hardLink);
else
[HelperTools configureFileProtection:NSFileProtectionCompleteUntilFirstUserAuthentication forFile:[hardLink path]];
}

//don't throw any error if the file aready exists, because it could be a rare collision (we only use 16 bit random numbers to keep the file prefix short)
if([_fileManager fileExistsAtPath:[hardLink path]])
DDLogWarn(@"Not hardlinking file '%@' to '%@': file already exists (maybe a rare collision?)...", cacheFile, hardLink);
else
{
DDLogVerbose(@"Hardlinking cache file '%@' to '%@'...", cacheFile, hardLink);
error = [HelperTools hardLinkOrCopyFile:cacheFile to:[hardLink path]];
if(error)
{
DDLogError(@"Error creating hardlink: %@", error);
@throw [NSException exceptionWithName:@"ERROR_WHILE_HARDLINKING_FILE" reason:[NSString stringWithFormat:@"%@", error] userInfo:@{@"error": error}];
DDLogVerbose(@"Hardlinking cache file '%@' to '%@'...", cacheFile, hardLink);
error = [HelperTools hardLinkOrCopyFile:cacheFile to:[hardLink path]];
if(error)
{
DDLogError(@"Error creating hardlink: %@", error);
@throw [NSException exceptionWithName:@"ERROR_WHILE_HARDLINKING_FILE" reason:[NSString stringWithFormat:@"%@", error] userInfo:@{@"error": error}];
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions Monal/Classes/MLXMPPManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ -(void) defaultSettings

[self upgradeBoolUserSettingsIfUnset:@"uploadImagesOriginal" toDefault:NO];

[self upgradeBoolUserSettingsIfUnset:@"hardlinkFiletransfersIntoDocuments" toDefault:YES];

// //always show onboarding on simulator for now
// #if TARGET_OS_SIMULATOR
// [[HelperTools defaultsDB] setBool:NO forKey:@"hasCompletedOnboarding"];
Expand Down

0 comments on commit 9cb55d5

Please sign in to comment.