Skip to content

Commit

Permalink
Fix export button in data settings not working
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Jan 7, 2025
1 parent 3ec81c9 commit d5fea35
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
27 changes: 25 additions & 2 deletions app/lib/settings/data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ class _DataSettingsPageState extends State<DataSettingsPage> {
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);
Expand All @@ -143,6 +143,29 @@ class _DataSettingsPageState extends State<DataSettingsPage> {
}));
}

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<void> _changeDataDirectory() async {
try {
final settingsCubit = context.read<SettingsCubit>();
Expand Down
1 change: 1 addition & 0 deletions metadata/en-US/changelogs/128.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d5fea35

Please sign in to comment.