Remote storage invalidation tweaks

This commit is contained in:
James King 2019-09-04 03:15:40 +01:00
parent 7445503580
commit 538bed982a
2 changed files with 6 additions and 7 deletions

View File

@ -290,7 +290,7 @@ public bool Delete()
if ( !remoteStorage.native.FileDelete( FileName ) ) return false; if ( !remoteStorage.native.FileDelete( FileName ) ) return false;
Exists = false; Exists = false;
remoteStorage.InvalidateFiles(); remoteStorage.FileDeleted( this );
return true; return true;
} }

View File

@ -76,8 +76,6 @@ public IEnumerable<RemoteFile> Files
public RemoteFile CreateFile( string path ) public RemoteFile CreateFile( string path )
{ {
path = NormalizePath( path ); path = NormalizePath( path );
InvalidateFiles();
var existing = Files.FirstOrDefault( x => x.FileName == path ); var existing = Files.FirstOrDefault( x => x.FileName == path );
return existing ?? new RemoteFile( this, path, client.SteamId, -1 ); return existing ?? new RemoteFile( this, path, client.SteamId, -1 );
} }
@ -88,8 +86,6 @@ public RemoteFile CreateFile( string path )
public RemoteFile OpenFile( string path ) public RemoteFile OpenFile( string path )
{ {
path = NormalizePath( path ); path = NormalizePath( path );
InvalidateFiles();
var existing = Files.FirstOrDefault( x => x.FileName == path ); var existing = Files.FirstOrDefault( x => x.FileName == path );
return existing; return existing;
} }
@ -163,8 +159,6 @@ internal void OnWrittenNewFile( RemoteFile file )
_files.Add( file ); _files.Add( file );
file.Exists = true; file.Exists = true;
InvalidateFiles();
} }
internal void InvalidateFiles() internal void InvalidateFiles()
@ -172,6 +166,11 @@ internal void InvalidateFiles()
_filesInvalid = true; _filesInvalid = true;
} }
internal void FileDeleted( RemoteFile file )
{
_files.Remove( file );
}
private void UpdateFiles() private void UpdateFiles()
{ {
if ( !_filesInvalid ) return; if ( !_filesInvalid ) return;