-
Notifications
You must be signed in to change notification settings - Fork 11
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
Improve Handling of noData Import Errors #2494
Changes from 17 commits
f9a856f
e32b283
de7c066
4ef9ada
9c6bc1e
d1bf50e
7bfe827
abf1998
ea45855
8dfc621
f9db576
902ff1a
b68d831
a42be42
68a10dd
d79475f
0bbbd5d
2814e2a
23524fa
71077dc
dc2b685
477ae70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Jump-Recolorable-16.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ final class FirefoxLoginReader { | |
case couldNotDetermineFormat = -2 | ||
|
||
case couldNotFindLoginsFile = 0 | ||
case couldNotFindKeyDB | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please don‘t change the case ordering to keep the original pixel error codes, add the new case to the end of the list, also consider adding a comment to keep the ordering when adding new errors |
||
case couldNotReadLoginsFile | ||
|
||
case key3readerStage1 | ||
|
@@ -49,7 +50,7 @@ final class FirefoxLoginReader { | |
|
||
var errorType: DataImport.ErrorType { | ||
switch type { | ||
case .couldNotFindLoginsFile, .couldNotReadLoginsFile: .noData | ||
case .couldNotFindLoginsFile, .couldNotFindKeyDB, .couldNotReadLoginsFile: .noData | ||
case .key3readerStage1, .key3readerStage2, .key3readerStage3, .key4readerStage1, .key4readerStage2, .key4readerStage3, .decryptUsername, .decryptPassword: .decryptionError | ||
case .couldNotDetermineFormat: .dataCorrupted | ||
case .requiresPrimaryPassword: .other | ||
|
@@ -94,7 +95,7 @@ final class FirefoxLoginReader { | |
func readLogins(dataFormat: DataFormat?) -> DataImportResult<[ImportedLoginCredential]> { | ||
var currentOperationType: ImportError.OperationType = .couldNotFindLoginsFile | ||
do { | ||
let dataFormat = try dataFormat ?? detectLoginFormat() ?? { throw ImportError(type: .couldNotDetermineFormat, underlyingError: nil) }() | ||
let dataFormat = try dataFormat ?? detectLoginFormat() ?? { throw ImportError(type: .couldNotFindKeyDB, underlyingError: nil) }() | ||
let keyData = try getEncryptionKey(dataFormat: dataFormat) | ||
let result = try reallyReadLogins(dataFormat: dataFormat, keyData: keyData, currentOperationType: ¤tOperationType) | ||
return .success(result) | ||
|
@@ -106,7 +107,7 @@ final class FirefoxLoginReader { | |
} | ||
|
||
func getEncryptionKey() throws -> Data { | ||
let dataFormat = try detectLoginFormat() ?? { throw ImportError(type: .couldNotDetermineFormat, underlyingError: nil) }() | ||
let dataFormat = try detectLoginFormat() ?? { throw ImportError(type: .couldNotFindKeyDB, underlyingError: nil) }() | ||
return try getEncryptionKey(dataFormat: dataFormat) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,8 @@ struct DataImportSummaryView: View { | |
self.model = model | ||
} | ||
|
||
private let zeroString = "0" | ||
|
||
var body: some View { | ||
VStack(alignment: .leading, spacing: 8) { | ||
{ | ||
|
@@ -61,7 +63,7 @@ struct DataImportSummaryView: View { | |
} | ||
if summary.duplicate > 0 { | ||
HStack { | ||
failureImage() | ||
skippedImage() | ||
Text("Duplicate Bookmarks Skipped:", | ||
comment: "Data import summary format of how many duplicate bookmarks (%lld) were skipped during import.") | ||
+ Text(" " as String) | ||
|
@@ -78,18 +80,38 @@ struct DataImportSummaryView: View { | |
} | ||
} | ||
|
||
case (.bookmarks, .failure): | ||
HStack { | ||
failureImage() | ||
Text("Bookmark import failed.", | ||
comment: "Data import summary message of failed bookmarks import.") | ||
case (.bookmarks, .failure(let error)): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fix the |
||
if error.errorType == .noData { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this can be split into different cases to remove the nested |
||
HStack { | ||
skippedImage() | ||
Text("Bookmarks:", | ||
comment: "Data import summary format of how many bookmarks (%lld) were successfully imported.") | ||
+ Text(" " as String) | ||
+ Text(zeroString).bold() | ||
} | ||
} else { | ||
HStack { | ||
failureImage() | ||
Text("Bookmark import failed.", | ||
comment: "Data import summary message of failed bookmarks import.") | ||
} | ||
} | ||
|
||
case (.passwords, .failure): | ||
HStack { | ||
failureImage() | ||
Text("Password import failed.", | ||
comment: "Data import summary message of failed passwords import.") | ||
case (.passwords, .failure(let error)): | ||
if error.errorType == .noData { | ||
HStack { | ||
skippedImage() | ||
Text("Passwords:", | ||
comment: "Data import summary format of how many passwords (%lld) were successfully imported.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fix the comment (no formatting here) |
||
+ Text(" " as String) | ||
+ Text(zeroString).bold() | ||
} | ||
} else { | ||
HStack { | ||
failureImage() | ||
Text("Password import failed.", | ||
comment: "Data import summary message of failed passwords import.") | ||
} | ||
} | ||
|
||
case (.passwords, .success(let summary)): | ||
|
@@ -126,6 +148,11 @@ private func failureImage() -> some View { | |
.frame(width: 16, height: 16) | ||
} | ||
|
||
private func skippedImage() -> some View { | ||
Image(.skipped) | ||
.frame(width: 16, height: 16) | ||
} | ||
|
||
#if DEBUG | ||
#Preview { | ||
VStack { | ||
|
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.
consider adding a comment for translator what is "%@" here,
BTW, will localization of the added copy be run as a follow-up task or is it in progress?
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 updated copy was added as part of ship review and the copy review is still open. Once approved I’ll run translation as part of this task.