@Test void deleteFilesModifiedBefore() throws Exception { long currentMillis = System.currentTimeMillis(); final long oldFilesTtl = 1000 * 60 * 10; final long pastMoment = currentMillis - 1000 * 60 * 15; FileEntry fileEntryToRemain1 = addFile(TEST_FILE_LOCATION); FileEntry fileEntryToRemain2 = addFile(SECOND_FILE_TEST_LOCATION); FileEntry fileEntryToDelete1 = addFile(TEST_FILE_LOCATION, spaceId, namespace, new Date(pastMoment)); FileEntry fileEntryToDelete2 = addFile(SECOND_FILE_TEST_LOCATION, spaceId, null, new Date(pastMoment)); String blobWithNoMetadataId = addBlobWithNoMetadata(); int deletedFiles = fileStorage.deleteFilesModifiedBefore(new Date(currentMillis - oldFilesTtl)); assertEquals(3, deletedFiles); assertFileExists(true, fileEntryToRemain1); assertFileExists(true, fileEntryToRemain2); assertFileExists(false, fileEntryToDelete1); assertFileExists(false, fileEntryToDelete2); assertNull(blobStoreContext.getBlobStore() .getBlob(CONTAINER, blobWithNoMetadataId)); }
@Override public int deleteFilesModifiedBefore(Date modificationTime) { return removeBlobsByFilter(blob -> filterByModificationTime(blob, modificationTime)); }
ObjectStoreFileStorage implements FileStorage { @Override public int deleteFilesModifiedBefore(Date modificationTime) { return removeBlobsByFilter(blob -> filterByModificationTime(blob, modificationTime)); } }
ObjectStoreFileStorage implements FileStorage { @Override public int deleteFilesModifiedBefore(Date modificationTime) { return removeBlobsByFilter(blob -> filterByModificationTime(blob, modificationTime)); } ObjectStoreFileStorage(BlobStore blobStore, String container); }
ObjectStoreFileStorage implements FileStorage { @Override public int deleteFilesModifiedBefore(Date modificationTime) { return removeBlobsByFilter(blob -> filterByModificationTime(blob, modificationTime)); } ObjectStoreFileStorage(BlobStore blobStore, String container); @Override void addFile(FileEntry fileEntry, File file); @Override List<FileEntry> getFileEntriesWithoutContent(List<FileEntry> fileEntries); @Override void deleteFile(String id, String space); @Override void deleteFilesBySpace(String space); @Override void deleteFilesBySpaceAndNamespace(String space, String namespace); @Override int deleteFilesModifiedBefore(Date modificationTime); @Override T processFileContent(String space, String id, FileContentProcessor<T> fileContentProcessor); }
ObjectStoreFileStorage implements FileStorage { @Override public int deleteFilesModifiedBefore(Date modificationTime) { return removeBlobsByFilter(blob -> filterByModificationTime(blob, modificationTime)); } ObjectStoreFileStorage(BlobStore blobStore, String container); @Override void addFile(FileEntry fileEntry, File file); @Override List<FileEntry> getFileEntriesWithoutContent(List<FileEntry> fileEntries); @Override void deleteFile(String id, String space); @Override void deleteFilesBySpace(String space); @Override void deleteFilesBySpaceAndNamespace(String space, String namespace); @Override int deleteFilesModifiedBefore(Date modificationTime); @Override T processFileContent(String space, String id, FileContentProcessor<T> fileContentProcessor);  }