Skip to content

Commit

Permalink
Update dataHandlers.js
Browse files Browse the repository at this point in the history
  • Loading branch information
CGDogan committed Sep 11, 2023
1 parent 2724054 commit 85d5e04
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions handlers/dataHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ FSChanged.added = function(req, res, next) {
// If contains any file from the parent path, do nothing
// otherwise, add it as a new entry
var parentDir = path.dirname(query.filepath);

// Here, we can be more fault tolerant and handle the case that despite still being an entry,
// it was somehow deleted from the filesystem.
// It may be replaced with any other file in the folder or the user requested path
// given that we verify that it exists.
if (JSON.stringify(x).includes(parentDir)) {
res.send({success: "another file from the same subdirectory is already in database"});
return;
Expand All @@ -421,6 +426,10 @@ FSChanged.added = function(req, res, next) {
}
return r.json();
}).then(data => {
if (data.error) {
res.send("SlideLoader error: the filepath points to an inexistant file?");
throw "";
}
data.filepath = filepath;
data.location = location;
data.name = name;
Expand Down

0 comments on commit 85d5e04

Please sign in to comment.