implemented file deletion

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-10-02 00:55:57 +02:00
parent 7284637057
commit 20d0247c90
2 changed files with 4 additions and 9 deletions

View File

@@ -92,10 +92,7 @@ public class FileModule extends BaseHandler implements FileService {
var filename = "/company/"+cid;
if (!path.empty()) filename += "/"+URLDecoder.decode(path.toString(),UTF_8);
if (!companies.membership(cid,user.id()) && !fileDb.isPermitted(user,filename)) throw forbidden("You are not allowed to access {0}",filename);
var file = new File(baseDir+filename);
if (!file.exists()) throw unprocessable("{0} does not exist!",filename);
return false;
return deleteFile(ex, new File(baseDir+filename));
}
private boolean deleteProjectFile(Path path, HttpExchange ex, UmbrellaUser user) throws IOException {
@@ -140,7 +137,7 @@ public class FileModule extends BaseHandler implements FileService {
}
private boolean deleteUserFile(Path path, HttpExchange ex, UmbrellaUser user) {
private boolean deleteUserFile(Path path, HttpExchange ex, UmbrellaUser user) throws IOException {
var userId = path.pop();
if (userId == null) throw missingFieldException(USER_ID);
long uid;
@@ -152,9 +149,7 @@ public class FileModule extends BaseHandler implements FileService {
var filename = "/user/"+uid;
if (!path.empty()) filename += "/"+URLDecoder.decode(path.toString(),UTF_8);
if (uid != user.id() && !fileDb.isPermitted(user,filename)) throw forbidden("You are not allowed to access {0}",filename);
var file = new File(baseDir+filename);
if (!file.exists()) throw unprocessable("{0} does not exist!",filename);
return false;
return deleteFile(ex, new File(baseDir+filename));
}
@Override