diff --git a/Facepunch.Steamworks/Client/RemoteStorage.FileStream.cs b/Facepunch.Steamworks/Client/RemoteStorage.FileStream.cs index 6b6a7b6..b0fe3e5 100644 --- a/Facepunch.Steamworks/Client/RemoteStorage.FileStream.cs +++ b/Facepunch.Steamworks/Client/RemoteStorage.FileStream.cs @@ -80,6 +80,8 @@ public override void Close() if ( _closed ) return; _closed = true; + _file.SizeInBytes = _written; + remoteStorage.native.FileWriteStreamClose( _handle ); _file.remoteStorage.OnWrittenNewFile( _file ); diff --git a/Facepunch.Steamworks/Client/RemoteStorage.cs b/Facepunch.Steamworks/Client/RemoteStorage.cs index 0330afa..45bd274 100644 --- a/Facepunch.Steamworks/Client/RemoteStorage.cs +++ b/Facepunch.Steamworks/Client/RemoteStorage.cs @@ -12,7 +12,7 @@ namespace Facepunch.Steamworks /// public class RemoteStorage : IDisposable { - private static string NormalizePath( string path ) + public static string NormalizePath( string path ) { // TODO: DUMB HACK ALERT @@ -79,7 +79,7 @@ public RemoteFile CreateFile( string path ) InvalidateFiles(); var existing = Files.FirstOrDefault( x => x.FileName == path ); - return existing ?? new RemoteFile( this, path, client.SteamId, 0 ); + return existing ?? new RemoteFile( this, path, client.SteamId, -1 ); } /// @@ -149,7 +149,17 @@ public byte[] ReadBytes( string path ) internal void OnWrittenNewFile( RemoteFile file ) { - if ( _files.Any( x => x.FileName == file.FileName ) ) return; + var match = _files.FirstOrDefault( x => x.FileName == file.FileName ); + + if ( match != null ) + { + if ( match != file ) + { + match.SizeInBytes = file.SizeInBytes; + } + + return; + } _files.Add( file ); file.Exists = true; @@ -177,7 +187,12 @@ private void UpdateFiles() { int size; var name = NormalizePath( native.GetFileNameAndSize( i, out size ) ); - var timestamp = native.GetFileTimestamp(name); + var timestamp = native.GetFileTimestamp( name ); + + if ( size == 0 ) + { + continue; + } var existing = _files.FirstOrDefault( x => x.FileName == name ); if ( existing == null )