mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-13 23:28:11 +03:00
Better handling of empty files in remote storage
This commit is contained in:
parent
26a64f64e7
commit
7445503580
@ -80,6 +80,8 @@ namespace Facepunch.Steamworks
|
|||||||
if ( _closed ) return;
|
if ( _closed ) return;
|
||||||
|
|
||||||
_closed = true;
|
_closed = true;
|
||||||
|
_file.SizeInBytes = _written;
|
||||||
|
|
||||||
remoteStorage.native.FileWriteStreamClose( _handle );
|
remoteStorage.native.FileWriteStreamClose( _handle );
|
||||||
|
|
||||||
_file.remoteStorage.OnWrittenNewFile( _file );
|
_file.remoteStorage.OnWrittenNewFile( _file );
|
||||||
|
@ -12,7 +12,7 @@ namespace Facepunch.Steamworks
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class RemoteStorage : IDisposable
|
public class RemoteStorage : IDisposable
|
||||||
{
|
{
|
||||||
private static string NormalizePath( string path )
|
public static string NormalizePath( string path )
|
||||||
{
|
{
|
||||||
// TODO: DUMB HACK ALERT
|
// TODO: DUMB HACK ALERT
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ namespace Facepunch.Steamworks
|
|||||||
|
|
||||||
InvalidateFiles();
|
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, 0 );
|
return existing ?? new RemoteFile( this, path, client.SteamId, -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -149,7 +149,17 @@ namespace Facepunch.Steamworks
|
|||||||
|
|
||||||
internal void OnWrittenNewFile( RemoteFile file )
|
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 );
|
_files.Add( file );
|
||||||
file.Exists = true;
|
file.Exists = true;
|
||||||
@ -179,6 +189,11 @@ namespace Facepunch.Steamworks
|
|||||||
var name = NormalizePath( native.GetFileNameAndSize( i, out 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 );
|
var existing = _files.FirstOrDefault( x => x.FileName == name );
|
||||||
if ( existing == null )
|
if ( existing == null )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user