diff --git a/app/lib/settings/data.dart b/app/lib/settings/data.dart index d0505f48f700..5b0725529c0e 100644 --- a/app/lib/settings/data.dart +++ b/app/lib/settings/data.dart @@ -127,9 +127,9 @@ class _DataSettingsPageState extends State { leading: const PhosphorIcon(PhosphorIconsLight.export), onTap: () async { - final directory = await _documentSystem + final directory = await _documentSystem.fileSystem .getRootDirectory(listLevel: allListLevel); - final archive = exportDirectory(directory); + final archive = _exportDirectory(directory); final encoder = ZipEncoder(); final bytes = encoder.encode(archive); exportZip(context, bytes); @@ -143,6 +143,29 @@ class _DataSettingsPageState extends State { })); } + Archive _exportDirectory(FileSystemDirectory directory, {int? lastModTime}) { + final archive = Archive(); + void addToArchive(FileSystemEntity asset) { + final path = asset.pathWithoutLeadingSlash; + if (asset is FileSystemFile) { + final data = asset.data; + if (data == null) return; + final file = ArchiveFile.bytes(path, data); + if (lastModTime != null) file.lastModTime = lastModTime; + archive.addFile(file); + } else if (asset is FileSystemDirectory) { + archive.addFile(ArchiveFile.directory(path)); + var assets = asset.assets; + for (var current in assets) { + addToArchive(current); + } + } + } + + addToArchive(directory); + return archive; + } + Future _changeDataDirectory() async { try { final settingsCubit = context.read(); diff --git a/metadata/en-US/changelogs/128.txt b/metadata/en-US/changelogs/128.txt index a73574888b57..a75be6143d98 100644 --- a/metadata/en-US/changelogs/128.txt +++ b/metadata/en-US/changelogs/128.txt @@ -6,5 +6,6 @@ This is a hotfix update, cherry picking some important fixes from the last 2.3.0 * Fix zoom slider is not centered * Fix shape detection list tile not clickable * Fix corrupting files when saving ([#777](https://github.com/LinwoodDev/Butterfly/issues/777)) +* Fix export button in data settings not working Read more here: https://linwood.dev/butterfly/2.2.4 \ No newline at end of file