Exemple #1
0
        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;
        }
Exemple #2
0
        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");
                    }
                }
            }
        }
Exemple #3
0
        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();
        }
Exemple #4
0
        void ProcessMissingObjects(IDictionary <string, PackageMetaData> cache, string package, Package.ObjectMap missing)
        {
            var metadata = RetrieveMetaData(cache, package);

            if ((metadata == null) || !metadata.Files.ContainsKey(missing.FO.FilePath))
            {
                return;
            }

            var match = metadata.Files[missing.FO.FilePath];
            var oPath = Repository.GetObjectPath(match);

            if (oPath.Exists)
            {
                missing.ExistingObject = match;
            }
        }
Exemple #5
0
 IEnumerable <Package.ObjectMap> GetMissingObjectMapping(IEnumerable <Package.ObjectMap> objects)
 => objects.Select(o => new { o, f = Repository.GetObjectPath(o.FO) })
 .Where(t => !t.f.Exists)
 .Select(t => t.o);