Clean the database of non-existing draggables on start
This commit is contained in:
parent
569052a06e
commit
c91159466d
9
plemp.js
9
plemp.js
|
@ -21,6 +21,13 @@ var app = express.createServer(form({ keepExtensions: true,
|
||||||
|
|
||||||
// Retrieve the draggables info.
|
// Retrieve the draggables info.
|
||||||
var draggables = db.load();
|
var draggables = db.load();
|
||||||
|
for (drag_id in draggables) {
|
||||||
|
if (!path.existsSync(__dirname + "/public/upload/" + drag_id)) {
|
||||||
|
console.log("Could not find draggable " + drag_id +
|
||||||
|
"; removing from database!");
|
||||||
|
delete draggables[drag_id];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Application settings and middleware configuration.
|
// Application settings and middleware configuration.
|
||||||
app.configure(function() {
|
app.configure(function() {
|
||||||
|
@ -93,9 +100,9 @@ app.get('/draggables/:id', function(req, res) {
|
||||||
// Stuff taken from the Camping implementation.
|
// Stuff taken from the Camping implementation.
|
||||||
var drag = draggables[drag_id];
|
var drag = draggables[drag_id];
|
||||||
var default_style = "left:" + drag.left + "px;top:" + drag.top + "px;";
|
var default_style = "left:" + drag.left + "px;top:" + drag.top + "px;";
|
||||||
var mime_type = drag.mime.split("/")
|
|
||||||
var title = drag.name || drag.title || 'Title not set';
|
var title = drag.name || drag.title || 'Title not set';
|
||||||
var content;
|
var content;
|
||||||
|
var mime_type = drag.mime.split("/")
|
||||||
switch (mime_type[0]) {
|
switch (mime_type[0]) {
|
||||||
case "image":
|
case "image":
|
||||||
content = '<img src="' + file_name + '"></img>';
|
content = '<img src="' + file_name + '"></img>';
|
||||||
|
|
Reference in a new issue