-
Notifications
You must be signed in to change notification settings - Fork 111
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
Preserve PDF annotations even when cache is reset #2965
Open
suhaibabsi-inst
wants to merge
5
commits into
master
Choose a base branch
from
bugfix/MBL-18069-PDF-Annotation-Saving
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+58
−7
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e5ea42e
Preserve PDF annotations even when cache is reset
suhaibabsi-inst 6e24ee9
Fix unit tests
suhaibabsi-inst 2cac257
More unit test for CacheManager
suhaibabsi-inst e56a00d
Migrate previously saved PDFs to the new one
suhaibabsi-inst ade8f6e
Update LoginSession.swift
suhaibabsi-inst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -140,7 +140,7 @@ class FileDetailsViewControllerTests: CoreTestCase { | |||
|
||||
func mock(_ file: APIFile, isExistingPDFFileWithAnnotations: Bool = false) { | ||||
api.mock(controller.files, value: file) | ||||
let base = isExistingPDFFileWithAnnotations ? URL.Directories.documents : URL.Directories.temporary | ||||
let base = isExistingPDFFileWithAnnotations ? URL.Directories.annotatedPDFs : URL.Directories.temporary | ||||
let url = base.appendingPathComponent("\(currentSession.uniqueID)/1/\(file.filename)") | ||||
XCTAssertNoThrow(try FileManager.default.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)) | ||||
XCTAssertTrue(FileManager.default.createFile(atPath: url.path, contents: Data())) | ||||
|
@@ -230,15 +230,16 @@ class FileDetailsViewControllerTests: CoreTestCase { | |||
|
||||
func testPrepLocalURLWithExistingPDFFile() { | ||||
let fileName = "\(currentSession.uniqueID)/1/File.pdf" | ||||
let docsUrl = URL.Directories.documents.appendingPathComponent(fileName) | ||||
let docsUrl = URL.Directories.annotatedPDFs.appendingPathComponent(fileName) | ||||
mock(APIFile.make(filename: "File.pdf", contentType: "application/pdf", mime_class: "pdf"), isExistingPDFFileWithAnnotations: true) | ||||
controller.view.layoutIfNeeded() | ||||
let result = controller.prepareLocalURL(fileName: fileName, mimeClass: "pdf", location: URL.Directories.temporary) | ||||
print(result) | ||||
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.
Suggested change
|
||||
XCTAssertEqual(result, docsUrl) | ||||
} | ||||
|
||||
func testMutatedPdfFileSavesToDocumentsDirectory() { | ||||
let expectedURL = URL.Directories.documents.appendingPathComponent("\(currentSession.uniqueID)/1/File.pdf") | ||||
let expectedURL = URL.Directories.annotatedPDFs.appendingPathComponent("\(currentSession.uniqueID)/1/File.pdf") | ||||
try? FileManager.default.removeItem(atPath: expectedURL.path) | ||||
XCTAssertFalse( FileManager.default.fileExists(atPath: expectedURL.path) ) | ||||
DocViewerViewController.hasPSPDFKitLicense = true | ||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I chose to call this here, and do it per session so to be targeting those folders relevant to this specific feature & session. Thus we do it lazily if there are multiple sessions.
There was an attempt to do it on app launch for all sessions at once, but there was a difficulty fetching all sessions that have files saved to
Documents
directory. Not all of them get persisted to Keychain as I was expecting.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.
The side effect of this is that non-migrated users will still lose their annotations in case someone hits the cache reset before all users logged in at least once, right? We could ask business if this is acceptable or not. Could we migrate all files based on just the directories and not relying on keychain? I think if a user logs out then we still keep its annotated pdfs but the session is removed from keychain.