Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
40428fa0
Unverified
Commit
40428fa0
authored
Jun 23, 2021
by
Jenn Magder
Committed by
GitHub
Jun 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
macOS unzip then rsync to delete stale artifacts (#85075)
parent
9e082f6c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
113 additions
and
0 deletions
+113
-0
os.dart
packages/flutter_tools/lib/src/base/os.dart
+39
-0
os_test.dart
packages/flutter_tools/test/general.shard/base/os_test.dart
+74
-0
No files found.
packages/flutter_tools/lib/src/base/os.dart
View file @
40428fa0
...
...
@@ -427,6 +427,45 @@ class _MacOSUtils extends _PosixUtils {
}
return
_hostPlatform
!;
}
// unzip, then rsync
@override
void
unzip
(
File
file
,
Directory
targetDirectory
)
{
if
(!
_processManager
.
canRun
(
'unzip'
))
{
// unzip is not available. this error message is modeled after the download
// error in bin/internal/update_dart_sdk.sh
throwToolExit
(
'Missing "unzip" tool. Unable to extract
${file.path}
.
\n
Consider running "brew install unzip".'
);
}
if
(
_processManager
.
canRun
(
'rsync'
))
{
final
Directory
tempDirectory
=
_fileSystem
.
systemTempDirectory
.
createTempSync
(
'flutter_
${file.basename}
.'
);
try
{
// Unzip to a temporary directory.
_processUtils
.
runSync
(
<
String
>[
'unzip'
,
'-o'
,
'-q'
,
file
.
path
,
'-d'
,
tempDirectory
.
path
],
throwOnError:
true
,
verboseExceptions:
true
,
);
for
(
final
FileSystemEntity
unzippedFile
in
tempDirectory
.
listSync
(
followLinks:
false
))
{
// rsync --delete the unzipped files so files removed from the archive are also removed from the target.
_processUtils
.
runSync
(
<
String
>[
'rsync'
,
'-av'
,
'--delete'
,
unzippedFile
.
path
,
targetDirectory
.
path
],
throwOnError:
true
,
verboseExceptions:
true
,
);
}
}
finally
{
tempDirectory
.
deleteSync
(
recursive:
true
);
}
}
else
{
// Fall back to just unzipping.
_logger
.
printTrace
(
'Unable to find rsync, falling back to direct unzipping.'
);
_processUtils
.
runSync
(
<
String
>[
'unzip'
,
'-o'
,
'-q'
,
file
.
path
,
'-d'
,
targetDirectory
.
path
],
throwOnError:
true
,
verboseExceptions:
true
,
);
}
}
}
class
_WindowsUtils
extends
OperatingSystemUtils
{
...
...
packages/flutter_tools/test/general.shard/base/os_test.dart
View file @
40428fa0
...
...
@@ -4,6 +4,7 @@
import
'package:file/file.dart'
;
import
'package:file/memory.dart'
;
import
'package:file_testing/file_testing.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/os.dart'
;
...
...
@@ -536,6 +537,79 @@ void main() {
);
});
group
(
'unzip on macOS'
,
()
{
testWithoutContext
(
'falls back to unzip when rsync cannot run'
,
()
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
fakeProcessManager
.
excludedExecutables
.
add
(
'rsync'
);
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
OperatingSystemUtils
macOSUtils
=
OperatingSystemUtils
(
fileSystem:
fileSystem
,
logger:
logger
,
platform:
FakePlatform
(
operatingSystem:
'macos'
),
processManager:
fakeProcessManager
,
);
final
Directory
targetDirectory
=
fileSystem
.
currentDirectory
;
fakeProcessManager
.
addCommand
(
FakeCommand
(
command:
<
String
>[
'unzip'
,
'-o'
,
'-q'
,
'foo.zip'
,
'-d'
,
targetDirectory
.
path
],
));
macOSUtils
.
unzip
(
fileSystem
.
file
(
'foo.zip'
),
targetDirectory
);
expect
(
fakeProcessManager
,
hasNoRemainingExpectations
);
expect
(
logger
.
traceText
,
contains
(
'Unable to find rsync'
));
});
testWithoutContext
(
'unzip and rsyncs'
,
()
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
OperatingSystemUtils
macOSUtils
=
OperatingSystemUtils
(
fileSystem:
fileSystem
,
logger:
BufferLogger
.
test
(),
platform:
FakePlatform
(
operatingSystem:
'macos'
),
processManager:
fakeProcessManager
,
);
final
Directory
targetDirectory
=
fileSystem
.
currentDirectory
;
final
Directory
tempDirectory
=
fileSystem
.
systemTempDirectory
.
childDirectory
(
'flutter_foo.zip.rand0'
);
fakeProcessManager
.
addCommands
(<
FakeCommand
>[
FakeCommand
(
command:
<
String
>[
'unzip'
,
'-o'
,
'-q'
,
'foo.zip'
,
'-d'
,
tempDirectory
.
path
,
],
onRun:
()
{
expect
(
tempDirectory
,
exists
);
tempDirectory
.
childDirectory
(
'dirA'
).
childFile
(
'fileA'
).
createSync
(
recursive:
true
);
tempDirectory
.
childDirectory
(
'dirB'
).
childFile
(
'fileB'
).
createSync
(
recursive:
true
);
},
),
FakeCommand
(
command:
<
String
>[
'rsync'
,
'-av'
,
'--delete'
,
tempDirectory
.
childDirectory
(
'dirA'
).
path
,
targetDirectory
.
path
,
]),
FakeCommand
(
command:
<
String
>[
'rsync'
,
'-av'
,
'--delete'
,
tempDirectory
.
childDirectory
(
'dirB'
).
path
,
targetDirectory
.
path
,
]),
]);
macOSUtils
.
unzip
(
fileSystem
.
file
(
'foo.zip'
),
fileSystem
.
currentDirectory
);
expect
(
fakeProcessManager
,
hasNoRemainingExpectations
);
expect
(
tempDirectory
,
isNot
(
exists
));
});
});
group
(
'display an install message when unzip cannot be run'
,
()
{
testWithoutContext
(
'Linux'
,
()
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment