-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.
Description
Future<void> _addDirectoryToZip({
required ZipEncoder encoder,
required Directory dir,
required String zipEntryPath,
required Set<String> ancestors,
}) async {
final canonical = await dir.resolveSymbolicLinks();
if (ancestors.contains(canonical)) {
return;
}
final newAncestors = {...ancestors, canonical};
await for (final fsEntity in dir.list(recursive: false, followLinks: false)) {
final name = path_lib.basename(fsEntity.path);
final entryPath =
zipEntryPath.isEmpty ? name : path_lib.join(zipEntryPath, name);
var real = fsEntity;
if (fsEntity is Link) {
final resolved = await fsEntity.resolveSymbolicLinks();
final type = FileSystemEntity.typeSync(resolved);
if (type == FileSystemEntityType.file) {
real = File(resolved);
} else if (type == FileSystemEntityType.directory) {
if (newAncestors.contains(resolved)) {
final dirFile = ArchiveFile.directory(entryPath);
encoder.add(dirFile);
continue; /// extract any method with this continue inside, and the produced code would be invalid
}
real = Directory(resolved);
} else {
throw FileSystemException('Broken symlink', fsEntity.path);
}
}
if (real is Directory) {
final dirFile = ArchiveFile.directory(entryPath);
encoder.add(dirFile);
await _addDirectoryToZip(
encoder: encoder,
dir: real,
zipEntryPath: entryPath,
ancestors: newAncestors,
);
}
if (real is File) {
final input = InputFileStream(real.path);
final archiveFile = ArchiveFile.stream(
entryPath,
input,
);
archiveFile.lastModTime =
real.lastModifiedSync().millisecondsSinceEpoch ~/ 1000;
archiveFile.compression = CompressionType.none;
encoder.add(archiveFile);
await input.close();
}
}
}Metadata
Metadata
Assignees
Labels
area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.