@@ -14,12 +14,26 @@ namespace ZkLobbyServer
1414 public class ReplayStorage
1515 {
1616 public static ReplayStorage Instance { get ; } = new ReplayStorage ( ) ;
17-
17+
1818 BlobContainerClient azureContainer ;
1919
20+ string basePath = GlobalConst . SpringieDataDir ;
21+
2022 internal ReplayStorage ( )
2123 {
22- azureContainer = new BlobContainerClient ( MiscVar . ReplaysConnectionString , MiscVar . ReplaysContainerName ) ;
24+ try
25+ {
26+ if ( string . IsNullOrEmpty ( MiscVar . ReplaysConnectionString ) || string . IsNullOrEmpty ( MiscVar . ReplaysContainerName ) )
27+ {
28+ Trace . TraceWarning ( "Replay storage not configured, replays won't be stored in blobs" ) ;
29+ return ;
30+ }
31+
32+ azureContainer = new BlobContainerClient ( MiscVar . ReplaysConnectionString , MiscVar . ReplaysContainerName ) ;
33+ } catch ( Exception ex )
34+ {
35+ Trace . TraceError ( "Error initializing replay storage: {0}" , ex . Message ) ;
36+ }
2337 }
2438
2539 public async Task < bool > UploadAndDeleteFileAsync ( string path )
@@ -65,17 +79,25 @@ public async Task<byte[]> GetFileContent(string replayName)
6579 return stream . ToArray ( ) ;
6680 }
6781
82+
83+ public byte [ ] GetLocalFileContent ( string replayName )
84+ {
85+ var path = Path . Combine ( basePath , "demos-server" , replayName ) ;
86+ if ( ! File . Exists ( path ) ) return null ;
87+ return File . ReadAllBytes ( path ) ;
88+ }
89+
6890 public async Task MigrateReplays ( )
6991 {
7092 // replays themselves
71- var files = Directory . GetFiles ( @"c:\Projekty\springie_spring\ demos-server") ;
93+ var files = Directory . GetFiles ( Path . Combine ( basePath , " demos-server") ) ;
7294 foreach ( var fi in files )
7395 {
7496 await UploadAndDeleteFileAsync ( fi ) ;
7597 }
7698
7799 // infologs
78- files = Directory . GetFiles ( @"c:\Projekty\springie_spring" , "infolog_*.txt" ) ;
100+ files = Directory . GetFiles ( basePath , "infolog_*.txt" ) ;
79101 foreach ( var fi in files )
80102 {
81103 await UploadAndDeleteFileAsync ( fi ) ;
0 commit comments