Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(580)

Unified Diff: sdk/lib/_internal/pub/lib/src/io.dart

Issue 1013423003: Support publishing packages with many long filenames. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/test/lish/many_files_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/io.dart
diff --git a/sdk/lib/_internal/pub/lib/src/io.dart b/sdk/lib/_internal/pub/lib/src/io.dart
index 9662d1f9151b246267b3b089e948b63a0b0731d7..d3c779b33f5814017475ed00b5980e8186b61566 100644
--- a/sdk/lib/_internal/pub/lib/src/io.dart
+++ b/sdk/lib/_internal/pub/lib/src/io.dart
@@ -933,7 +933,7 @@ Future<bool> _extractTarGzWindows(Stream<List<int>> stream,
///
/// Returns a [ByteStream] that emits the contents of the archive.
ByteStream createTarGz(List contents, {baseDir}) {
- return new ByteStream(futureStream(new Future.sync(() {
+ return new ByteStream(futureStream(new Future.sync(() async {
var buffer = new StringBuffer();
buffer.write('Creating .tag.gz stream containing:\n');
contents.forEach((file) => buffer.write('$file\n'));
@@ -950,41 +950,51 @@ ByteStream createTarGz(List contents, {baseDir}) {
}).toList();
if (Platform.operatingSystem != "windows") {
- var args = ["--create", "--gzip", "--directory", baseDir];
- args.addAll(contents);
- // TODO(nweiz): It's possible that enough command-line arguments will
- // make the process choke, so at some point we should save the arguments
- // to a file and pass them in via --files-from for tar and -i@filename
- // for 7zip.
- return startProcess("tar", args).then((process) => process.stdout);
+ var args = [
+ "--create",
+ "--gzip",
+ "--directory",
+ baseDir,
+ "--files-from",
+ "/dev/stdin"
+ ];
+
+ var process = await startProcess("tar", args);
+ process.stdin.add(UTF8.encode(contents.join("\n")));
+ process.stdin.close();
+ return process.stdout;
}
// Don't use [withTempDir] here because we don't want to delete the temp
// directory until the returned stream has closed.
var tempDir = createSystemTempDir();
- return new Future.sync(() {
+
+ try {
+ // Create the file containing the list of files to compress.
+ var contentsPath = path.join(tempDir, "files.txt");
+ writeTextFile(contentsPath, contents.join("\n"));
+
// Create the tar file.
var tarFile = path.join(tempDir, "intermediate.tar");
- var args = ["a", "-w$baseDir", tarFile];
- args.addAll(contents.map((entry) => '-i!$entry'));
+ var args = ["a", "-w$baseDir", tarFile, "@$contentsPath"];
// We're passing 'baseDir' both as '-w' and setting it as the working
// directory explicitly here intentionally. The former ensures that the
// files added to the archive have the correct relative path in the
// archive. The latter enables relative paths in the "-i" args to be
// resolved.
- return runProcess(pathTo7zip, args, workingDir: baseDir).then((_) {
- // GZIP it. 7zip doesn't support doing both as a single operation.
- // Send the output to stdout.
- args = ["a", "unused", "-tgzip", "-so", tarFile];
- return startProcess(pathTo7zip, args);
- }).then((process) => process.stdout);
- }).then((stream) {
- return stream.transform(onDoneTransformer(() => deleteEntry(tempDir)));
- }).catchError((e) {
+ await runProcess(pathTo7zip, args, workingDir: baseDir);
+
+ // GZIP it. 7zip doesn't support doing both as a single operation.
+ // Send the output to stdout.
+ args = ["a", "unused", "-tgzip", "-so", tarFile];
+ return (await startProcess(pathTo7zip, args))
+ .stdout
+ .transform(onDoneTransformer(() => deleteEntry(tempDir)));
+ } catch (_) {
deleteEntry(tempDir);
- throw e;
- });
+ rethrow;
+ }
})));
}
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/test/lish/many_files_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698