internal FileStorageComparisonCache(string path, int comparisonsToKeep) { _path = Path.Combine(path, ComparisonCacheSubFolderName); string oldPath = Path.Combine(path, OldComparisonCacheSubFolderName); FileStorageUtils.MigrateDirectory(oldPath, _path); cleanupOldComparisons(comparisonsToKeep); }
internal FileStorageRevisionCache(string path, int revisionsToKeep) { Path = System.IO.Path.Combine(path, RevisionsSubFolderName); string oldPath = System.IO.Path.Combine(path, OldRevisionsSubFolderName); FileStorageUtils.MigrateDirectory(oldPath, Path); cleanupOldRevisions(revisionsToKeep); renameOldRevisions(); }
private void renameOldRevisions() { if (!Directory.Exists(Path)) { return; } IEnumerable <string> allSubdirectories; try { allSubdirectories = Directory.GetDirectories(Path, "*", SearchOption.TopDirectoryOnly); } catch (Exception ex) // Any exception from Directory.GetDirectories() { ExceptionHandlers.Handle(String.Format("Cannot obtain a list of subdirectories at {0}", Path), ex); return; } foreach (string oldPath in allSubdirectories) { string oldRevisionDirName; try { oldRevisionDirName = System.IO.Path.GetFileName(oldPath); } catch (ArgumentException ex) { ExceptionHandlers.Handle(String.Format("Cannot obtain directory name from path {0}", oldPath), ex); continue; } if (oldRevisionDirName.Length != FileStorageUtils.FullShaLength) { continue; } // oldRevisionDirName is a full git SHA string newRevisionDirName = FileStorageUtils.ConvertShaToRevision(oldRevisionDirName); string newPath = System.IO.Path.Combine(Path, newRevisionDirName); FileStorageUtils.MigrateDirectory(oldPath, newPath); } }