Beispiel #1
0
    public void TryParseSuccess()
    {
        var digest = new ManifestDigest();

        digest.TryParse("sha1new=test1");
        digest.TryParse("sha256new_test2");
        digest.AvailableDigests.Should().Equal("sha256new_test2", "sha1new=test1");
    }
Beispiel #2
0
    public void ParseIDNoOverwrite()
    {
        var digest = new ManifestDigest("sha1=test");

        digest.TryParse("sha1=test2");
        digest.Sha1.Should().Be("test", because: "Once a digest value has been set, ID values should not overwrite it");
    }
Beispiel #3
0
    public void TryParseInvalid()
    {
        var digest = new ManifestDigest();

        digest.TryParse("invalid");
        digest.AvailableDigests.Should().BeEmpty();
    }
Beispiel #4
0
    public void TryParseEmptyString()
    {
        var digest = new ManifestDigest();

        digest.TryParse("");
        digest.AvailableDigests.Should().BeEmpty();
    }
Beispiel #5
0
    /// <inheritdoc />
    public void Purge(ITaskHandler handler)
    {
        #region Sanity checks
        if (handler == null)
        {
            throw new ArgumentNullException(nameof(handler));
        }
        #endregion

        var paths = Directory.GetDirectories(Path).Where(path =>
        {
            var digest = new ManifestDigest();
            digest.TryParse(System.IO.Path.GetFileName(path));
            return(digest.AvailableDigests.Any());
        }).ToList();
        if (paths.Count == 0)
        {
            return;
        }

        if (MissingAdminRights)
        {
            throw new NotAdminException(Resources.MustBeAdminToRemove);
        }

        handler.RunTask(ForEachTask.Create(
                            name: string.Format(Resources.DeletingDirectory, Path),
                            target: paths,
                            work: path => RemoveInner(path, handler, allowAutoShutdown: true)));

        RemoveDeleteInfoFile();
    }
Beispiel #6
0
    /// <inheritdoc/>
    public IEnumerable <ManifestDigest> ListAll()
    {
        if (!Directory.Exists(Path))
        {
            return(Enumerable.Empty <ManifestDigest>());
        }

        var result = new List <ManifestDigest>();

        foreach (string path in Directory.GetDirectories(Path))
        {
            var digest = new ManifestDigest();
            digest.TryParse(System.IO.Path.GetFileName(path));
            if (digest.AvailableDigests.Any())
            {
                result.Add(digest);
            }
        }
        return(result);
    }