Page MenuHomePhabricator

Implement tools to manage backup files
ClosedPublic

Authored by marcin on Jan 2 2024, 4:18 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Jul 3, 3:15 PM
Unknown Object (File)
Wed, Jul 3, 2:27 PM
Unknown Object (File)
Tue, Jul 2, 11:53 PM
Unknown Object (File)
Tue, Jul 2, 6:14 PM
Unknown Object (File)
Tue, Jul 2, 1:05 PM
Unknown Object (File)
Mon, Jul 1, 7:53 PM
Unknown Object (File)
Mon, Jul 1, 5:20 AM
Unknown Object (File)
Mon, Jul 1, 5:12 AM
Subscribers

Details

Summary

This differential introduces API that allows to get the path to a backup file associated with particular backup ID and to remove backup files directory at once during
log-out.

Test Plan
  1. Call PlatformSpecificTools::getBackupFilePath() in C++ code which execution can be easily triggered manually (e.x. draft update).
  2. Trigger execution of the code above.
  3. Download application container from XCode or examine Device File Explorer in Android studio to ensure that empty backup directory was created.
  4. Log out.
  5. Examine application file system again. Ensure directory was deleted.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Rebase to update commit message

marcin requested review of this revision.Jan 2 2024, 6:04 AM
kamil requested changes to this revision.Jan 5 2024, 4:20 AM

As we discussed in the office, the convention should be:

  • backup_1234 for compaction
  • backup_1234_attachments for attachments

where 1234 is the backup ID.

Also, initially, I thought it was better to implement getting only a directory in PlatformSpecificTools and create a file path in shared C++ implementation, but on the other hand, now are 100% confident about the separator correctness so it's probably okay as it is.

native/android/app/src/main/java/app/comm/android/fbjni/PlatformSpecificTools.java
41–42 ↗(On Diff #35128)
52 ↗(On Diff #35128)

shouldn't we throw if mkdirs() return false?

82 ↗(On Diff #35128)

same as above, I think we should throw if delete returns false

native/ios/Comm/PlatformSpecificTools.mm
54 ↗(On Diff #35128)

I think we can attach err message here to make it more descriptive

87–98 ↗(On Diff #35128)

we can move it to a separate method and avoid code duplication with getBackupFilePath()

This revision now requires changes to proceed.Jan 5 2024, 4:20 AM
native/android/app/src/main/java/app/comm/android/fbjni/PlatformSpecificTools.java
32 ↗(On Diff #35128)

This probably also needs to be exposes to C++/Rust as I will need to iterate over the files in the directory.

  1. Update backup files naming schema.
  2. Make a public method to get just backup directory path
  3. Improve error handling in Java files.
native/android/app/src/main/java/app/comm/android/fbjni/PlatformSpecificTools.java
54 ↗(On Diff #35356)

Did a little research and it looks like methods we are using here are throwing one of two exceptions: SecurityException or NullPointerException. So by narrowing down the catch scope we can throw inside try without risking that we will catch our own exception in the same code that is throwing (which wouldn't make much sense).

kamil added inline comments.
native/android/app/src/main/java/app/comm/android/fbjni/PlatformSpecificTools.java
83 ↗(On Diff #35356)

I think this is what you meant

This revision is now accepted and ready to land.Jan 9 2024, 3:10 AM

Fix Android compilation errors

This revision was automatically updated to reflect the committed changes.