public PlasmaDownloader(IPlasmaDownloaderConfig config, SpringScanner scanner, SpringPaths springPaths) {
     SpringPaths = springPaths;
     Config = config;
     this.scanner = scanner;
     //torrentDownloader = new TorrentDownloader(this);
     packageDownloader = new PackageDownloader(this);
 }
 public PlasmaDownloader(IResourcePresenceChecker checker, SpringPaths paths)
 {
     SpringPaths = paths;
     this.scanner = checker;
     //torrentDownloader = new TorrentDownloader(this);
     packageDownloader = new PackageDownloader(this);
 }
 public static void ResetConfigs(SpringPaths paths, PackageDownloader.Version ver)
 {
     if (ver != null)
     {
         var oldVers = LoadFromDisk(paths);
         var newVers = LoadFromChobby(ver, paths);
         if (oldVers != null && newVers != null)
         {
             foreach (var kvp in newVers.Versions)
             {
                 int oldVerNumber;
                 if (oldVers.Versions.TryGetValue(kvp.Key, out oldVerNumber) && oldVerNumber < kvp.Value)
                 {
                     try
                     {
                         File.Delete(Path.Combine(paths.WritableDirectory, kvp.Key));
                     }
                     catch (Exception ex)
                     {
                         Trace.TraceWarning("Error deleting config file {0} : {1}", kvp.Key, ex);
                     }
                 }
             }
         }
         (newVers ?? new ConfigVersions()).SaveToDisk(paths);
     }
 }
 private dynamic ExtractEngineFromLua(PackageDownloader.Version ver)
 {
     if (ver != null)
     {
         var mi = ver.ReadFile(paths, "modinfo.lua");
         var lua = new Lua();
         var luaEnv = lua.CreateEnvironment();
         dynamic result = luaEnv.DoChunk(new StreamReader(mi), "dummy.lua");
         var engineVersion = result.engine;
         return engineVersion;
     }
     return null;
 }
 private static void ExtractDefaultConfigs(SpringPaths paths, PackageDownloader.Version ver)
 {
     if (ver != null)
     {
         foreach (var f in defaultConfigs)
         {
             var target = Path.Combine(paths.WritableDirectory, Path.GetFileName(f));
             if (!File.Exists(target))
             {
                 var content = ver.ReadFile(paths, f);
                 if (content != null) File.WriteAllBytes(target, content.ToArray());
             }
         }
     }
 }
 public static ConfigVersions LoadFromChobby(PackageDownloader.Version ver, SpringPaths paths)
 {
     var ms = ver?.ReadFile(paths, FilePathInChobby);
     if (ms != null) return TryDeserialize(Encoding.UTF8.GetString(ms.ToArray()));
     return null;
 }