public async Task <AbsolutePath> Ingest(AbsolutePath file) { var hash = await file.FileHashAsync(); var path = ArchivePath(hash); if (HaveArchive(hash)) { await file.DeleteAsync(); return(path); } var newPath = _settings.ArchivePath.Combine(hash.ToHex()); await file.MoveToAsync(newPath); return(path); }
public async Task DeletedFilesAreRemoved() { await AddFile(TEST_TXT, "This is a test"); await AddTestRoot(); var file = context.Index.ByRootPath[TEST_TXT]; Assert.NotNull(file); Assert.Equal(14, file.Size); Assert.Equal(Hash.FromBase64("qX0GZvIaTKM="), file.Hash); await TEST_TXT.DeleteAsync(); await AddTestRoot(); Assert.DoesNotContain(TEST_TXT, context.Index.AllFiles.Select(f => f.AbsoluteName)); }