void RenameExistingObject(IDictionary <string, Status> statusDic, string destName, string srcName) { var status = statusDic[destName]; status.Progress = 0; status.Action = RepoStatus.Renaming; RenameFilePath(WorkingPath.GetChildFileWithName(srcName), WorkingPath.GetChildFileWithName(destName)); status.EndOutput(); }
void ProcessRemoved(IDictionary <string, Status> statusDic, string x) { var status = statusDic[x]; status.Progress = 0; status.Action = RepoStatus.Removing; Tools.FileUtil.Ops.DeleteWithRetry(WorkingPath.GetChildFileWithName(x).ToString()); status.EndOutput(); }
void UpdateFileMetaData(PackageMetaData metaData, FileObjectMapping x, ICollection <string> paths) { metaData.Size += new FileInfo(Path.Combine(WorkingPath.ToString(), x.FilePath)).Length; var path = Repository.GetObjectPath(x.Checksum); if (paths.Contains(path.ToString())) { return; } paths.Add(path.ToString()); metaData.SizePacked += new FileInfo(path.ToString()).Length; }
public void Close() { if (WorkingPath.DirectoryExists && WorkingPath.IsChildOfDirectory(privateWorkingRootPath)) { Log.Info(TAG, $"Deleting private working path {WorkingPath}"); try { Directory.Delete(WorkingPath, true); } catch (Exception e) { Log.Error(TAG, $"Unable to delete private working copy {WorkingPath}", e); } } }
void ProcessObject(bool skipWhenLocalFileMatches, FileObjectMapping o, ICollection <FileObjectMapping> validObjects) { if (skipWhenLocalFileMatches) { // We can also skip objects that already match in the working directory so that we don't waste time on compressing or copying objects needlessly // this however could create more bandwidth usage in case the user in the future deletes working files, and tries to get the version again // in that case the objects will need to be redownloaded, or at least patched up from other possible available objects. var path = WorkingPath.GetChildFileWithName(o.FilePath); if (path.Exists && Repository.GetChecksum(path).Equals(o.Checksum)) { validObjects.Add(o); if (Common.Flags.Verbose) { MainLog.Logger.Info( $"Marking {o.FilePath} ({o.Checksum}) as valid, because the local object matches"); } return; } var oPath = Repository.GetObjectPath(o.Checksum); if (oPath.Exists) { validObjects.Add(o); if (Common.Flags.Verbose) { MainLog.Logger.Info( $"Marking {o.FilePath} ({o.Checksum}) as valid, because the packed object exists"); } // Don't readd object because we can't validate if the Checksum is in order.. } } else { var ob = Repository.GetObject(o.Checksum); if (ob == null) { return; } var oPath = Repository.GetObjectPath(o.Checksum); if (oPath.Exists && Repository.GetChecksum(oPath).Equals(ob.ChecksumPack)) { validObjects.Add(o); if (Common.Flags.Verbose) { MainLog.Logger.Info( $"Marking {o.FilePath} ({o.Checksum}) as valid, because the packed object matches"); } } } }
void CopyExistingWorkingFile(IDictionary <string, Status> statusDic, string destName, string srcName) { var status = statusDic[destName]; status.Progress = 0; status.Action = RepoStatus.Copying; var srcFile = WorkingPath.GetChildFileWithName(srcName); var destFile = WorkingPath.GetChildFileWithName(destName); destFile.ParentDirectoryPath.MakeSurePathExists(); Tools.FileUtil.Ops.CopyWithRetry(srcFile, destFile); status.EndOutput(); }
IAbsoluteFilePath[] GetWorkingPathFiles(bool withRemoval, IOrderedEnumerable <FileObjectMapping> mappings) { if (!withRemoval) { return (mappings.Select(x => WorkingPath.GetChildFileWithName(x.FilePath)) .Where(x => x.Exists).ToArray()); } var files = Repository.GetFiles(WorkingPath); return(files .OrderByDescending(x => Tools.FileUtil.SizePrediction(x.FileName)).ToArray()); }
void ProcessModified(IDictionary <string, Status> statusDic, FileObjectMapping fcm, Action <double, long?> act) { var status = statusDic[fcm.FilePath]; status.Progress = 0; status.Action = RepoStatus.Unpacking; var destFile = WorkingPath.GetChildFileWithName(fcm.FilePath); var packedFile = Repository.GetObjectPath(fcm.Checksum); destFile.ParentDirectoryPath.MakeSurePathExists(); Tools.Compression.Gzip.UnpackSingleGzip(packedFile, destFile, new StatusWrapper(status, act)); status.EndOutput(); }
public MainWindow() { settings = new Settings(); settings.readSettings(); testList = new List <string>(); InitializeComponent(); showInCenter(); this.DataContext = this; timer = new DispatcherTimer(); workingPath = new WorkingPath(); cmbBox_chipher.DisplayMemberPath = "Code"; checkWorkingFolder(); }
Tuple <string, string, string> GetCppInfo() { var cppFile = WorkingPath.GetChildFileWithName("mod.cpp"); if (!cppFile.Exists) { return(new Tuple <string, string, string>(null, null, null)); } var fileContent = File.ReadAllText(cppFile.ToString()); var p = new ModCppParser(fileContent); var name = p.GetName(); var description = p.GetDescription(); var author = p.GetAuthor(); return(Tuple.Create(name, description, author)); }
public bool CanSaveBAT() { if (!CanGenerateCommand()) { return(false); } if ((GeneratedCommands == null) || (GeneratedCommands.Count == 0)) { return(false); } if (WorkingPath.Trim() == string.Empty) { return(false); } return(true); }
void ProcessMissingObject(Package.ObjectMap o, ICollection <Package.ObjectMap> resolvedObjects) { var f = WorkingPath.GetChildFileWithName(o.FO.FilePath); if (!f.Exists) { return; } var status = new Status(o.FO.FilePath, StatusRepo) { Action = RepoStatus.Packing, RealObject = GetObjectPathFromChecksum(o.FO) }; var checksum = Repository.GetChecksum(f); this.Logger().Info("Found local previous version file for {0}. Compressing to {1}", o.FO.FilePath, checksum); Repository.CompressObject(f, checksum); o.ExistingObject = checksum; resolvedObjects.Add(o); status.EndOutput(); }
PublishModModel BuildPublishModel(string registerInfo) { var yml = WorkingPath.GetChildDirectoryWithName(".rsync\\.pack") .GetChildFileWithName(".repository.yml"); var cppInfo = GetCppInfo(); return(new PublishModModel { PackageName = MetaData.Name, Revision = yml.Exists ? (int)SyncEvilGlobal.Yaml.NewFromYamlFile <RepoVersion>(yml).Version : 0, Version = MetaData.GetVersionInfo(), Size = MetaData.SizePacked, SizeWd = MetaData.Size, Readme = GetReadme(), Changelog = GetChangelog(), License = GetLicense(), CppName = cppInfo.Item1, Description = cppInfo.Item2.TruncateNullSafe(500), Author = cppInfo.Item3, RegisterInfo = registerInfo }); }
public void Dispose() { WorkingPath.Dispose(); _destinationDirectory?.Dispose(); _sourceDirectory?.Dispose(); }
IEnumerable <IAbsoluteDirectoryPath> GetEmptyDirectories(IEnumerable <string> remove) => remove.Select(Path.GetDirectoryName) .Distinct() .Select(x => WorkingPath.GetChildDirectoryWithName(x)) .Where(x => Tools.FileUtil.IsDirectoryEmpty(x));
void CrippleSixSyncIfExists() { Tools.FileUtil.Ops.DeleteIfExists(Path.Combine(WorkingPath.ToString(), Legacy.SixSync.Repository.RepoFolderName, ".repository.yml")); }
void OnCheckoutWithoutRemoval(ProgressLeaf progressLeaf) { WorkingPath.MakeSurePathExists(); ProcessCheckout(progressLeaf, false); }
public void Checkout(ProgressLeaf progressLeaf, bool confirmChecksums = true) { WorkingPath.MakeSurePathExists(); ProcessCheckout(progressLeaf, true, confirmChecksums); WriteTag(); }