示例#1
0
 private void Init(FileStorageConfig fileStorageConfig)
 {
     //logger.LogInformation("FileStorage: Init starts");
     infoFile   = fileStorageConfig.Directory + "filestorageinfo.json";
     storageDir = fileStorageConfig.Directory + "storage/";
     if (!Directory.Exists(fileStorageConfig.Directory))
     {
         Console.WriteLine("FileStorage::Init: No directory found, creating.");
         DirectoryInfo root    = new DirectoryInfo(fileStorageConfig.Directory);
         DirectoryInfo storage = new DirectoryInfo(storageDir);
         root.Create();
         storage.Create();
     }
     fileStorageInfo = new FileStorageInfo();
     if (!File.Exists(infoFile))
     {
         fileStorageInfo.DumpTo(infoFile);
     }
     else
     {
         fileStorageInfo.Load(infoFile);
     }
     Console.WriteLine("FileStorage: Init ends");
 }
示例#2
0
 public FileStorage(FileStorageConfig fileStorageConfig)
 {
     this.fileStorageConfig = fileStorageConfig;
     lockGroup = new LockGroup <string>(fileStorageConfig.LockCount, s => s.GetHashCode());
     Init(fileStorageConfig);
 }