Esempio n. 1
0
        /// <summary>Creates, or updates a zip archive of the folder in a git repository.</summary>
        /// <param name="id">A unique identifier for this archive.</param>
        /// <param name="relativePathToZip">The relative path inside the git repo that you want to create an archive for.</param>
        /// <param name="outPath">The output path for the zip file (and a related meta file). This should not be a directory in 
        /// the git repository.</param>
        public bool Zip(string id, string relativePathToZip, string outPath)
        {
            string pathToZip = IO.Path.Combine(rootPath, relativePathToZip);

            var files = IO.Directory
                .GetFiles(pathToZip, "*", IO.SearchOption.AllDirectories)
                .Select(f => new IO.FileInfo(f).LastWriteTimeUtc)
                .OrderByDescending(t => t);
            var latestFileUpdated = files
                .FirstOrDefault();

            //Commit latestCommit = repository.Commits.LatestCommitFor(relativePathToZip);
            DateTimeOffset lastUpdated = DateTimeOffset.Now;
            if (latestFileUpdated != null) {
                lastUpdated = latestFileUpdated;
            }

            Zipper z = new Zipper(id, outPath);
            if (z.DoesArchiveRequireRebuilding(lastUpdated)) {
                z.WriteArchive(pathToZip);
                return true;
            }

            return false;
        }
Esempio n. 2
0
        /// <summary>Delete the zip file's configuration file. This ensures a rebuild next time Zip is called.</summary>
        /// <returns>The path to the configuration file that was deleted. It shouldn't exist at this point.</returns>
        public string ResetZipConfig(string id, string outpath)
        {
            Zipper z = new Zipper(id, outpath);
            if (IO.File.Exists(z.ConfigFilePath)) {
                IO.File.Delete(z.ConfigFilePath);
            }

            return z.ConfigFilePath;
        }