Browse Source

implemented file deletion

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
module/files
Stephan Richter 1 month ago
parent
commit
20d0247c90
  1. 11
      files/src/main/java/de/srsoftware/umbrella/files/FileModule.java
  2. 2
      frontend/src/routes/files/Index.svelte

11
files/src/main/java/de/srsoftware/umbrella/files/FileModule.java

@ -92,10 +92,7 @@ public class FileModule extends BaseHandler implements FileService { @@ -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 { @@ -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 { @@ -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

2
frontend/src/routes/files/Index.svelte

@ -75,7 +75,7 @@ @@ -75,7 +75,7 @@
let json = await res.json();
children.dirs = json.dirs ? json.dirs : {};
children.files = json.files ? json.files : {};
children.title = json.title ? json.title : {};
children.title = json.title ? json.title : path;
delete_allowed = json.delete;
yikes();
}

Loading…
Cancel
Save