Skip to content

Commit b0f9597

Browse files
committed
Add zipDirectoryPosix to create POSIX-compliant archives
Introduces the zipDirectoryPosix method to ensure archive entries use POSIX-style paths. Updates archive creation to use this method for better cross-platform compatibility.
1 parent 68b5e84 commit b0f9597

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/serious_python/bin/package_command.dart

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,7 @@ class PackageCommand extends Command {
432432
// create archive
433433
stdout.writeln(
434434
"Creating app archive at ${dest.path} from a temp directory");
435-
final encoder = ZipFileEncoder();
436-
await encoder.zipDirectory(tempDir, filename: dest.path);
435+
await zipDirectoryPosix(tempDir, dest);
437436

438437
// create hash file
439438
stdout.writeln("Writing app archive hash to ${dest.path}.hash");
@@ -517,6 +516,21 @@ class PackageCommand extends Command {
517516
return proc.exitCode;
518517
}
519518

519+
Future<void> zipDirectoryPosix(Directory source, File dest) async {
520+
final encoder = ZipFileEncoder();
521+
encoder.create(dest.path);
522+
await for (final entity
523+
in source.list(recursive: true, followLinks: false)) {
524+
if (entity is! File) {
525+
continue;
526+
}
527+
final relativePath = path.relative(entity.path, from: source.path);
528+
final posixPath = path.posix.joinAll(path.split(relativePath));
529+
encoder.addFile(entity, posixPath);
530+
}
531+
encoder.close();
532+
}
533+
520534
Future<int> runPython(List<String> args,
521535
{Map<String, String>? environment}) async {
522536
if (_pythonDir == null) {

0 commit comments

Comments
 (0)