-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix palette cloud sync #4061
base: master
Are you sure you want to change the base?
fix palette cloud sync #4061
Conversation
sync cloud/items code with android; fix crash after starting sync with cloud; minor fixes;
Sources/Helpers/OAAppSettings.m
Outdated
@@ -4037,8 +4037,21 @@ - (instancetype) init | |||
[_profilePreferences setObject:_locationIcon forKey:@"location_icon"]; | |||
|
|||
_appModeOrder = [OACommonInteger withKey:appModeOrderKey defValue:0]; | |||
[_appModeOrder setModeDefaultValue:@0 mode:OAApplicationMode.DEFAULT]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NSArray *modes = @[
OAApplicationMode.DEFAULT,
OAApplicationMode.CAR,
...
];
and for (NSInteger i = 0; i < modes.count; i++) {}
import Foundation | ||
|
||
@objcMembers | ||
final class BackupUtils: NSObject { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this class? is it possible to drop it and use existing classes like OABackupDbHelper and OABackupHelper?
@@ -67,7 +67,7 @@ - (BOOL)shouldShowDuplicates | |||
|
|||
- (long)localModifiedTime | |||
{ | |||
return _historyMarkersHelper.getMarkersHistoryLastModifiedTime; | |||
return [_historyMarkersHelper getMarkersHistoryLastModifiedTime]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
@@ -93,7 +93,9 @@ - (void) apply | |||
} | |||
|
|||
for (OAHistoryItem *historyItem in self.appliedItems) | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
UserDefaults.standard.set(fileHashes.asDictionary(), forKey: Self.key) | ||
} | ||
|
||
func isHashUpdated(_ localFile: OALocalFile) -> Bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this method should have only return OAUtilities.fileMD5(localFile.filePath) != fileHashes.getValue(forKey: localFile.filePath)
@@ -85,11 +86,12 @@ - (OABackupInfo *) doInBackground | |||
{ | |||
BOOL fileChangedLocally = localFile.localModifiedTime > (localFile.uploadTime / 1000); | |||
BOOL fileChangedRemotely = remoteFile.updatetimems > localFile.uploadTime; | |||
BOOL needToUpload = [hashHelper isHashUpdated:localFile]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use additional variable. fileChangedLocally
seems to be enough.
BTW - may we use existing needMd5Digest
/ getMd5Digest
/ setMd5Digest
in this issue?
if (exportType == nil || ![OAExportSettingsType isTypeEnabled:exportType]) | ||
continue; | ||
|
||
BOOL hasRemoteFile = _uniqueRemoteFiles[localFile.getTypeFileName] != nil; | ||
BOOL fileToDelete = [info.localFilesToDelete containsObject:localFile]; | ||
if (!hasRemoteFile && !fileToDelete) | ||
BOOL needToUpload = [hashHelper isHashUpdated:localFile]; | ||
if (!hasRemoteFile && !fileToDelete && needToUpload) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like not needed if fileChangedLocally
will be used
} | ||
|
||
func setHash(withFileItem fileItem: OAFileSettingsItem) { | ||
guard fileItem.subtype == .subtypeColorPalette else { return } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class should not check types directly. Should be done via SettingsItem
, like with needMd5Digest
return exists | ||
} | ||
|
||
static func updateCacheForItems(_ items: [OASettingsItem]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be better name? What is cache in this method?
@@ -179,6 +180,7 @@ - (void)onSettingsImportFinished:(BOOL)succeed items:(NSArray<OASettingsItem *> | |||
{ | |||
if (succeed) | |||
{ | |||
[BackupUtils updateCacheForItems:items]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double call?
No description provided.