Skip to content

Commit

Permalink
chore: modify the threshold of StorageRelatedTasks and add file delet…
Browse files Browse the repository at this point in the history
…ion log
  • Loading branch information
D-D-H committed Oct 21, 2023
1 parent 3575a91 commit a6f31af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import java.nio.file.Path;
import java.time.Instant;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -286,7 +287,12 @@ public NamedResource handleDownloadRequest(long fileId) throws Throwable {

@Override
public void deleteOldestFile() {
fileRepo.findFirstByOrderByCreatedTimeDesc().ifPresent(this::doDelete);
Optional<FileEntity> optional = fileRepo.findFirstByOrderByCreatedTimeDesc();
if (optional.isPresent()) {
FileEntity file = optional.get();
doDelete(file);
log.info("File '{} ({})' is deleted", file.getOriginalName(), file.getUniqueName());
}
}

private FileEntity getFileEntityByIdAndCheckAuthority(long id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class StorageRelatedTasks extends ConfigurationAccessor {

private final StorageService storageService;

private static final double THRESHOLD = 0.15;
private static final double THRESHOLD = 0.05;

public StorageRelatedTasks(LockSupport lockSupport,
FileRepo fileRepo,
Expand Down

0 comments on commit a6f31af

Please sign in to comment.