예제 #1
0
        async Task TryMoveOldCopyToHistory(string backupDir, string sourceFile, byte[] destContent)
        {
            if (_historyProvider == null)
            {
                return;
            }
            var historyDirName = _historyProvider.ConvertFileNameToHistoryDirectoryName(sourceFile);
            var historyDirPath = _destination.CombinePath(backupDir, historyDirName);

            if (await _destination.IsDirectoryExists(historyDirPath))
            {
                await TryCleanupHistoryDirectory(historyDirPath);
            }
            else
            {
                await _destination.CreateDirectory(historyDirPath);
            }
            var nameInHistory = _historyProvider.ConvertFileNameToVersionedFileName(sourceFile);
            var pathInHistory = _destination.CombinePath(historyDirPath, nameInHistory);

            _logger?.LogDebug($"TryMoveOldCopyToHistory('{backupDir}', '{sourceFile}'): create file in history: '{pathInHistory}'");
            await _destination.CreateFile(pathInHistory, destContent);

            _changeValidator?.OnFileChanged(pathInHistory);
        }
예제 #2
0
 public void HistoryReturnsCorrectFileName()
 {
     Assert.NotNull(_history.ConvertFileNameToVersionedFileName("temp"));
 }