@@ -83,20 +83,32 @@ class DevFSFileContent extends DevFSContent {
|
||||
void _stat() {
|
||||
if (_linkTarget != null) {
|
||||
// Stat the cached symlink target.
|
||||
_fileStat = _linkTarget.statSync();
|
||||
return;
|
||||
final FileStat fileStat = _linkTarget.statSync();
|
||||
if (fileStat.type == FileSystemEntityType.notFound) {
|
||||
_linkTarget = null;
|
||||
} else {
|
||||
_fileStat = fileStat;
|
||||
return;
|
||||
}
|
||||
}
|
||||
_fileStat = file.statSync();
|
||||
if (_fileStat.type == FileSystemEntityType.link) {
|
||||
final FileStat fileStat = file.statSync();
|
||||
_fileStat = fileStat.type == FileSystemEntityType.notFound ? null : fileStat;
|
||||
if (_fileStat != null && _fileStat.type == FileSystemEntityType.link) {
|
||||
// Resolve, stat, and maybe cache the symlink target.
|
||||
final String resolved = file.resolveSymbolicLinksSync();
|
||||
final FileSystemEntity linkTarget = fs.file(resolved);
|
||||
// Stat the link target.
|
||||
_fileStat = linkTarget.statSync();
|
||||
if (devFSConfig.cacheSymlinks) {
|
||||
final FileStat fileStat = linkTarget.statSync();
|
||||
if (fileStat.type == FileSystemEntityType.notFound) {
|
||||
_fileStat = null;
|
||||
_linkTarget = null;
|
||||
} else if (devFSConfig.cacheSymlinks) {
|
||||
_linkTarget = linkTarget;
|
||||
}
|
||||
}
|
||||
if (_fileStat == null) {
|
||||
printError('Unable to get status of file "${file.path}": file not found.');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -106,21 +118,29 @@ class DevFSFileContent extends DevFSContent {
|
||||
bool get isModified {
|
||||
final FileStat _oldFileStat = _fileStat;
|
||||
_stat();
|
||||
return _oldFileStat == null || _fileStat.modified.isAfter(_oldFileStat.modified);
|
||||
if (_oldFileStat == null && _fileStat == null)
|
||||
return false;
|
||||
return _oldFileStat == null || _fileStat == null || _fileStat.modified.isAfter(_oldFileStat.modified);
|
||||
}
|
||||
|
||||
@override
|
||||
bool isModifiedAfter(DateTime time) {
|
||||
final FileStat _oldFileStat = _fileStat;
|
||||
_stat();
|
||||
return _oldFileStat == null || time == null || _fileStat.modified.isAfter(time);
|
||||
if (_oldFileStat == null && _fileStat == null)
|
||||
return false;
|
||||
return time == null
|
||||
|| _oldFileStat == null
|
||||
|| _fileStat == null
|
||||
|| _fileStat.modified.isAfter(time);
|
||||
}
|
||||
|
||||
@override
|
||||
int get size {
|
||||
if (_fileStat == null)
|
||||
_stat();
|
||||
return _fileStat.size;
|
||||
// Can still be null if the file wasn't found.
|
||||
return _fileStat?.size ?? 0;
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user