NCBACK-35 add cloud for save when download last chunk and after protected
Test Workflow / test (push) Successful in 3s

This commit is contained in:
vladp
2026-02-13 21:11:30 +07:00
parent 03a330b570
commit 2985d84b04
10 changed files with 305 additions and 30 deletions
@@ -241,6 +241,10 @@ public class FileEntityService {
fileEntityRepository.delete(fileEntity);
}
public void deleteFromDisk(String deleteFilePath) throws IOException {
Files.deleteIfExists(Paths.get(deleteFilePath));
}
@Transactional(readOnly = true)
public long getUserStorageUsed(Long userId) {
Long totalSize = fileEntityRepository.getTotalSizeByUserId(userId);
@@ -256,12 +260,11 @@ public class FileEntityService {
}
@Transactional
public void writeProtectedFile(String id, byte[] data, String fileExt) throws IOException {
public FileEntity writeProtectedFile(String id, byte[] data, String fileExt) throws IOException {
FileEntity fileEntity = fileEntityRepository.findById(id)
.orElseThrow(() -> new RuntimeException("File not found: " + id));
String extension = determineFileExtension(fileExt, fileEntity);
log.info("EXTENSION: {}", extension);
Path protectedFilePath = prepareProtectedPath(fileEntity, extension);
if (Files.exists(protectedFilePath)) {
@@ -276,7 +279,7 @@ public class FileEntityService {
fileEntity.setFileExtension(extension);
fileEntity.setProtectionStatus(ProtectionStatus.PROTECTED);
fileEntityRepository.save(fileEntity);
return fileEntityRepository.save(fileEntity);
}
public void clearTempFiles(long userId) throws IOException {