Exemplo n.º 1
0
        public void DeleteByIndex(string potName, int index = 0)
        {
            PotDirectory potDirectory = PotDirectory.FromPotName(potName);

            if (!potDirectory.IsValid)
            {
                throw new Exception($"There is no pot with name '{potName}'.");
            }

            SnapshotFile snapshotFile = potDirectory.GetSnapshotFiles()
                                        .Skip(index)
                                        .FirstOrDefault();

            snapshotFile?.Delete();
        }
Exemplo n.º 2
0
        public bool DeleteByExactDateTime(string potName, DateTime dateTime)
        {
            PotDirectory potDirectory = PotDirectory.FromPotName(potName);

            if (!potDirectory.IsValid)
            {
                throw new Exception($"There is no pot with name '{potName}'.");
            }

            SnapshotFile snapshotFile = potDirectory.GetSnapshotFiles()
                                        .FirstOrDefault(x => x.CreationTime.HasValue && x.CreationTime.Value == dateTime);

            if (snapshotFile == null)
            {
                return(false);
            }

            snapshotFile.Delete();
            return(true);
        }