dev comment logic for check max users
Test Workflow / test (push) Successful in 4s

This commit is contained in:
vladp
2026-02-21 21:35:13 +07:00
parent ca10d4d130
commit f932bb47f0
@@ -326,6 +326,16 @@ public class FileUploadServiceImpl implements FileUploadService {
fileSimilarityService.hasDuplicatesByHash(finalFilePath ,session.getFileType());
File file = new File(finalFilePath);
if (session.getFileType().startsWith("audio") && !isWavFile(file)) {
session.setStatus(UploadStatus.FAILED);
session.setLastError("wav file not have RIFF header");
sessionRepository.save(session);
throw new FileUploadException("Failed to upload chunk: .wav file not have RIFF header");
}
FileProtector.Type type = "document".equals(session.getFileType()) ?
FileProtector.Type.DOC : FileProtector.Type.valueOf(session.getFileType().toUpperCase());
@@ -403,6 +413,29 @@ public class FileUploadServiceImpl implements FileUploadService {
}
}
//TODO убрать когда научимся защищать другие типы
public boolean isWavFile(File file) {
if (file == null || !file.exists() || file.length() < 12) {
return false;
}
try (FileInputStream fis = new FileInputStream(file)) {
byte[] header = new byte[4];
int bytesRead = fis.read(header);
if (bytesRead < 4) {
return false;
}
return header[0] == 82 && header[1] == 73 &&
header[2] == 70 && header[3] == 70;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
private int protectCost(String fileType) {
int cost = 0;