コード例 #1
0
ファイル: Package.cs プロジェクト: dkv01/withSIX.Desktop
        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();
        }
コード例 #2
0
ファイル: Package.cs プロジェクト: dkv01/withSIX.Desktop
        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();
        }
コード例 #3
0
ファイル: Package.cs プロジェクト: dkv01/withSIX.Desktop
        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");
                    }
                }
            }
        }
コード例 #4
0
ファイル: Package.cs プロジェクト: dkv01/withSIX.Desktop
        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();
        }
コード例 #5
0
ファイル: Package.cs プロジェクト: dkv01/withSIX.Desktop
        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();
        }
コード例 #6
0
ファイル: Package.cs プロジェクト: dkv01/withSIX.Desktop
        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());
        }
コード例 #7
0
ファイル: Package.cs プロジェクト: dkv01/withSIX.Desktop
        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));
        }
コード例 #8
0
ファイル: Package.cs プロジェクト: dkv01/withSIX.Desktop
        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();
        }