Exemple #1
0
        public void RestorePackage(string name, string tag)
        {
            CachedPackageInfo cachedPackage = GetAllCachedPackages().FirstOrDefault(p => p.Name == name && p.Tag == tag);

            if (cachedPackage == null)
            {
                return;
            }

            fileService.Unzip(cachedPackage.Path);

            foreach (FileHistoryEntry deletedFile in cachedPackage.FolderVersion.Files.Where(f => f.EditType == FileHistoryType.Deleted))
            {
                File.Delete(deletedFile.Path);
            }
        }
Exemple #2
0
        private void AddCachedPackage(PackageInfo packageInfo, string path)
        {
            var info = new CachedPackageInfo
            {
                Name          = packageInfo.Name,
                Tag           = packageInfo.Tag,
                Hash          = packageInfo.Hash,
                Path          = path,
                FolderVersion = JsonConvert.DeserializeObject <FolderVersionEntry>(packageInfo.VersionInfo)
            };

            List <CachedPackageInfo> allPackages = GetAllCachedPackages();

            allPackages.Add(info);
            File.WriteAllText(dbFilePath, JsonConvert.SerializeObject(allPackages));
        }