コード例 #1
0
        public int CountOfLimits(BackUpInfo backUp, int index, CleaningByAmount cleaningByAmount, CleaningByDate cleaningByDate, CleaningBySize cleaningBySize)
        {
            int cnt = 0;

            if (isCleaningByAmount && cleaningByAmount.isGoOutOfLimit(backUp, index))
            {
                cnt++;
            }
            if (isCleaningByDate && cleaningByDate.isGoOutOfLimit(backUp, index))
            {
                cnt++;
            }
            if (isCleaningBySize && cleaningBySize.isGoOutOfLimit(backUp, index))
            {
                cnt++;
            }
            return(cnt);
        }
コード例 #2
0
        public override void Clean(BackUpInfo backUp)
        {
            CleaningByAmount cleaningByAmount = new CleaningByAmount(maxRestorePointsCount);
            CleaningByDate   cleaningByDate   = new CleaningByDate();
            CleaningBySize   cleaningBySize   = new CleaningBySize(maxBackupSize);

            indexesToRemove = new List <int>();
            for (int i = 0; i < backUp.listOfRestorePoints.Count; i++)
            {
                int currentCnt = CountOfLimits(backUp, i, cleaningByAmount, cleaningByDate, cleaningBySize);
                if (currentCnt > 0)
                {
                    if (flag || (!flag && currentCnt == 3))
                    {
                        if (backUp.listOfRestorePoints[i] is IncrementalRestorePoint)
                        {
                            IncrementalRestorePoint tmp = (IncrementalRestorePoint)backUp.listOfRestorePoints[i];
                            if (tmp.id == tmp.deltaPointId)
                            {
                                throw new Exception("Error! You can't delete this restore point");
                            }
                            else
                            {
                                indexesToRemove.Add(i);
                            }
                        }
                        else
                        {
                            indexesToRemove.Add(i);
                        }
                    }
                }
            }
            RemoveByIndex(backUp);
            backUp.saveAlgo.Save(backUp);
        }