Skip to content

Commit c815ebe

Browse files
committedMar 4, 2020
Fixed issue with trying to remove db or user multiple times
1 parent 71a1b19 commit c815ebe

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed
 

‎scripts/expire.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
const { aql, query, db } = require("@arangodb");
33
const users = require("@arangodb/users");
44

5-
const expirationTime = (4 * 60 * 60 * 1000) // 4 hours
5+
const expirationTime = (4 * 60 * 60 * 1000) // 4 hours or use (30 * 1000) for 30 seconds
66
const expired = [];
77

88
let dbs = query`
@@ -16,12 +16,18 @@ dbs.toArray().map((d) => {
1616
let cleanupCollection = query`
1717
FOR key IN ${expired}
1818
FOR i IN tutorialInstances
19-
FILTER i._key
19+
FILTER i._key == key
2020
INSERT {email: i.email, username: i.username, dbName: i.dbName} INTO expiredtutorialInstances
21-
REMOVE { _key: i._key } IN tutorialInstances`;
21+
REMOVE { _key: key } IN tutorialInstances`;
2222

2323
function removeDatabase(dbName, key, username) {
24-
users.remove(username);
25-
db._dropDatabase(dbName);
26-
expired.push(key);
24+
if (users.exists(username)){
25+
users.remove(username);
26+
}
27+
try {
28+
db._dropDatabase(dbName);
29+
expired.push(key);
30+
} catch (err) {
31+
32+
}
2733
}

0 commit comments

Comments
 (0)
Please sign in to comment.