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
f767f860
Unverified
Commit
f767f860
authored
Feb 02, 2023
by
Jesús S Guerrero
Committed by
GitHub
Feb 02, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check if directory exists before listing content (#119748)
parent
322d10e1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
cache.dart
packages/flutter_tools/lib/src/cache.dart
+4
-0
cache_test.dart
packages/flutter_tools/test/general.shard/cache_test.dart
+40
-0
No files found.
packages/flutter_tools/lib/src/cache.dart
View file @
f767f860
...
...
@@ -1242,6 +1242,10 @@ class ArtifactUpdater {
continue
;
}
for
(
Directory
directory
=
file
.
parent
;
directory
.
absolute
.
path
!=
_tempStorage
.
absolute
.
path
;
directory
=
directory
.
parent
)
{
// Handle race condition when the directory is deleted before this step
if
(!
directory
.
existsSync
())
{
break
;
}
if
(
directory
.
listSync
().
isNotEmpty
)
{
break
;
}
...
...
packages/flutter_tools/test/general.shard/cache_test.dart
View file @
f767f860
...
...
@@ -398,6 +398,30 @@ void main() {
expect
(
staleFile
,
isNot
(
exists
));
});
testWithoutContext
(
'Try to remove without a parent'
,
()
async
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
Directory
parent
=
fileSystem
.
directory
(
'dir'
);
parent
.
createSync
();
final
Directory
child
=
parent
.
childDirectory
(
'child'
);
child
.
createSync
();
final
Directory
tempStorage
=
parent
.
childDirectory
(
'temp'
);
tempStorage
.
createSync
();
final
FakeArtifactUpdaterDownload
fakeArtifact
=
FakeArtifactUpdaterDownload
(
operatingSystemUtils:
FakeOperatingSystemUtils
(),
logger:
BufferLogger
.
test
(),
fileSystem:
fileSystem
,
tempStorage:
tempStorage
,
httpClient:
HttpClient
(),
platform:
FakePlatform
(),
allowedBaseUrls:
<
String
>[]
);
final
File
file
=
child
.
childFile
(
'file'
);
file
.
createSync
();
fakeArtifact
.
addFiles
(<
File
>[
file
]);
child
.
deleteSync
(
recursive:
true
);
fakeArtifact
.
removeDownloadedFiles
();
});
testWithoutContext
(
'IosUsbArtifacts verifies executables for libimobiledevice in isUpToDateInner'
,
()
async
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
Cache
cache
=
Cache
.
test
(
fileSystem:
fileSystem
,
processManager:
FakeProcessManager
.
any
());
...
...
@@ -1212,3 +1236,19 @@ class FakeArtifactUpdater extends Fake implements ArtifactUpdater {
@override
void
removeDownloadedFiles
()
{
}
}
class
FakeArtifactUpdaterDownload
extends
ArtifactUpdater
{
FakeArtifactUpdaterDownload
({
required
super
.
operatingSystemUtils
,
required
super
.
logger
,
required
super
.
fileSystem
,
required
super
.
tempStorage
,
required
super
.
httpClient
,
required
super
.
platform
,
required
super
.
allowedBaseUrls
});
void
addFiles
(
List
<
File
>
files
)
{
downloadedFiles
.
addAll
(
files
);
}
}
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