Skip to content

Commit 7fe9df7

Browse files
authored
Merge pull request #40 from picoded/mongodb-fs-root-oid-bug
Fix MongoDB "root" oid from appearing in keySet
2 parents c56702a + c28f765 commit 7fe9df7

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/main/java/picoded/dstack/mongodb/MongoDB_FileWorkspaceMap.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void systemSetup() {
108108
// We insert a "root" object, to ensure the tables are initialized
109109
// ---
110110
if (!fullRawPathExist("root")) {
111-
setupAnchorFile_withFullRawPath("root", "root", "root");
111+
setupAnchorFile_withFullRawPath("", "root", "root");
112112
}
113113

114114
// Lets setup the index for the metadata fields (which is not enabled by default)
@@ -926,7 +926,12 @@ public Set<String> keySet() {
926926
// Lets iterate the search
927927
try (MongoCursor<String> cursor = search.iterator()) {
928928
while (cursor.hasNext()) {
929-
ret.add(cursor.next());
929+
String oid = cursor.next();
930+
// older version of DStack initialized a "root" folder, which is invalid
931+
if( oid == null || oid.equals("root") || oid.equals("") ) {
932+
continue;
933+
}
934+
ret.add(oid);
930935
}
931936
}
932937

0 commit comments

Comments
 (0)