mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-25 14:15:47 +03:00
Better handling of empty files in remote storage
This commit is contained in:
parent
26a64f64e7
commit
7445503580
@ -80,6 +80,8 @@ public override void Close()
|
||||
if ( _closed ) return;
|
||||
|
||||
_closed = true;
|
||||
_file.SizeInBytes = _written;
|
||||
|
||||
remoteStorage.native.FileWriteStreamClose( _handle );
|
||||
|
||||
_file.remoteStorage.OnWrittenNewFile( _file );
|
||||
|
@ -12,7 +12,7 @@ namespace Facepunch.Steamworks
|
||||
/// </summary>
|
||||
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 );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -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 )
|
||||
|
Loading…
Reference in New Issue
Block a user