-
Notifications
You must be signed in to change notification settings - Fork 29
Attachment package refactor #311
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
base: main
Are you sure you want to change the base?
Conversation
…handling in powersync_attachments_stream package and added unit tests
packages/powersync_attachments_stream/lib/src/local_storage.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/src/local_storage.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/src/attachment_service.dart
Outdated
Show resolved
Hide resolved
…/powersync.dart into attachment-package-refactor
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.
Some more comments from a quick look.
Also, I assume supabase-todolist-new-attachments was copied from the old one? For a review it would be easier if the changes were in the same project so I can see what has changed. But that can happen in the end.
export 'src/implementations/attachment_context.dart'; |
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 is this exporting the implementation?
export 'src/implementations/attachment_service.dart'; | ||
export 'src/implementations/attachment_context.dart'; | ||
export 'src/abstractions/remote_storage.dart'; |
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 is already exported by common.dart
static AttachmentState fromInt(int value) { | ||
if (value < 0 || value >= AttachmentState.values.length) { | ||
throw ArgumentError('Invalid value for AttachmentState: $value'); | ||
} | ||
return AttachmentState.values[value]; | ||
} | ||
|
||
int toInt() => index; |
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.
You can actually put these in the enum class itself if you add a semicolon after the last enum member (archived
in this case).
/// Class used to implement the attachment queue. | ||
/// Requires a database client, remote storage adapter, and an attachment directory name. | ||
class AttachmentQueue { | ||
final dynamic db; |
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 does this have to be dynamic
?
final Duration syncInterval; | ||
final int archivedCacheLimit; | ||
final Duration syncThrottleDuration; | ||
final List<String>? subdirectories; |
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 we still need explicit subdirectories or can we make the local storage adapter create subdirectories on demand?
I remember one issue with the previous implementation was that users wanted to create subdirectories based on data (e.g. one directory per list
in the standard todolist demo), and that's very inconvenient with a list like this.
setUp(() async { | ||
tempDir = await Directory.systemTemp.createTemp('local_storage_test_'); | ||
storage = IOLocalStorage(tempDir); | ||
}); | ||
|
||
tearDown(() async { | ||
if (await tempDir.exists()) { | ||
await tempDir.delete(recursive: true); | ||
} | ||
}); |
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.
It's not a requirement , but you can use the test_descriptor which is really convenient when you need each test to operate on an independent directory. It can also be used to assert the state of the file system after some IOLocalStorage
operations.
No description provided.