Skip to content

Conversation

@krushnarout
Copy link
Member

await _walFile!.copy(_walBackupFile!.path);

crash is caused by copying wal file inside the documents dir, and the fix is to move the file to Application Support where macos allows internal write and backup operations

ref: https://stackoverflow.com/questions/66304002/what-is-the-difference-between-getapplicationsupportdirectory-and-getlibrarydire

closes #3940

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly moves the WAL and backup files from the documents directory to the application support directory within WalFileManager to fix a crash on macOS. This is a good fix. However, the review identified several other places in the codebase, specifically within app/lib/services/wals.dart, where getApplicationDocumentsDirectory() is still being used for similar file operations related to WALs. To fully resolve the issue and ensure consistency, these instances should also be updated to use getApplicationSupportDirectory(). A detailed comment has been added to point out the exact locations.


static Future<void> init() async {
final directory = await getApplicationDocumentsDirectory();
final directory = await getApplicationSupportDirectory();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This change is correct for WalFileManager. However, the codebase contains other instances of getApplicationDocumentsDirectory() that are also used for managing WAL files and should be updated as well to ensure consistency and fully resolve the issue on macOS.

Specifically, these locations in app/lib/services/wals.dart need to be updated:

  • Wal.getFilePath (line 212)
  • SDCardWalSync._flushToDisk (line 351)
  • FlashPageWalSync._saveBatchToFile (line 1268)

These methods also handle WAL files and should use getApplicationSupportDirectory() to prevent the same crash. It's recommended to address these in this PR to complete the fix.

@mdmohsin7
Copy link
Member

This happens only on macos right? then I think the right option is to only change it for macos. And also wal doesn't really get used on mac

@krushnarout
Copy link
Member Author

krushnarout commented Jan 1, 2026

This happens only on macos right? then I think the right option is to only change it for macos. And also wal doesn't really get used on mac

Yes, I think this will be good too, I've changed to macos only

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FlutterError - FileSystemException: Cannot copy file

3 participants