Skip to content

Commit 4e1a3ec

Browse files
authored
Update MongoDB_FileWorkspaceMap.java
1 parent a45b0b6 commit 4e1a3ec

File tree

1 file changed

+0
-132
lines changed

1 file changed

+0
-132
lines changed

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

Lines changed: 0 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -947,138 +947,6 @@ public Set<String> backend_getFileAndFolderPathSet(final String oid, String fold
947947
// Filter and return the final set
948948
return backend_filterPathSet(ret, folderPath, minDepth, maxDepth, 0);
949949
}
950-
951-
952-
/**
953-
* Internal utility function used to filter a path set, and remove items that does not match.
954-
* This is used to help filter raw results, from existing implementation
955-
*
956-
* - its folderPath prefix
957-
* - min/max depth
958-
* - any / file / folder
959-
*
960-
* @param rawSet (note this expect the full RAW paths, without removing the folderPath prefix)
961-
* @param folderPath the folder path prefix to search and match against, and truncate
962-
* @param minDepth (0 = all items, 1 = must be in atleast a folder, 2 = folder, inside a folder)
963-
* @param maxDepth
964-
* @param pathType (0 = any, 1 = file, 2 = folder)
965-
* @return
966-
*/
967-
@Override
968-
protected Set<String> backend_filterPathSet(final Set<String> rawSet, final String folderPath,
969-
final int minDepth, final int maxDepth, final int pathType) {
970-
971-
// Normalize the folder path
972-
String searchPath = folderPath;
973-
if (searchPath == null || searchPath.equals("/")) {
974-
searchPath = "";
975-
}
976-
int searchPathLen = searchPath.length();
977-
978-
// // Debugging stuff
979-
System.out.println( "#" );
980-
System.out.println( "searchPath: "+searchPath );
981-
System.out.println( "searchPathLen: "+searchPathLen );
982-
System.out.println( "minDepth: "+minDepth );
983-
System.out.println( "maxDepth: "+maxDepth );
984-
System.out.println( "pathType: "+pathType );
985-
System.out.println( "rawSet: "+ConvertJSON.fromObject(rawSet) );
986-
987-
// Return set
988-
Set<String> ret = new HashSet<>();
989-
990-
// Get the keyset, and iterate it
991-
for (String key : rawSet) {
992-
993-
// Skip the root folder of a workspace
994-
if (key.equals("") || key.equals("/")) {
995-
continue;
996-
}
997-
998-
// If folder does not match - skip
999-
if (searchPathLen > 0 && !key.startsWith(searchPath)) {
1000-
continue;
1001-
}
1002-
1003-
// If folder path match - store it - maybe?
1004-
String subPath = key.substring(searchPathLen);
1005-
1006-
// Skip the root folder of a subpath
1007-
if (subPath.equals("")) {
1008-
ret.add("/");
1009-
continue;
1010-
}
1011-
1012-
// Skip the root folder of a subpath
1013-
if (subPath.equals("/")) {
1014-
continue;
1015-
}
1016-
1017-
// No filtering is needed, store and continue
1018-
if (maxDepth <= 0 && minDepth <= 0) {
1019-
// Does no checks, add and continue
1020-
ret.add(subPath);
1021-
continue;
1022-
}
1023-
1024-
// Lets perform path filtering
1025-
// ---
1026-
1027-
// Lets filter out the ending "/"
1028-
String filteredSubPath = subPath;
1029-
if (filteredSubPath.endsWith("/")) {
1030-
filteredSubPath = filteredSubPath.substring(0, filteredSubPath.length() - 1);
1031-
}
1032-
1033-
// Split and count
1034-
String[] splitSubPath = filteredSubPath.split("/");
1035-
int subPathLength = (filteredSubPath.length() <= 0) ? 0 : splitSubPath.length;
1036-
1037-
// Check min depth - skip key if check failed
1038-
if (minDepth > 0 && subPathLength < minDepth) {
1039-
continue;
1040-
}
1041-
1042-
// Check max depth - skip key if check failed
1043-
if (maxDepth > 0 && subPathLength > maxDepth) {
1044-
continue;
1045-
}
1046-
1047-
// Alrighto - lets check file / folder type - and add it in
1048-
// ---
1049-
1050-
// Ignore empty
1051-
if (subPath.isEmpty()) {
1052-
continue;
1053-
}
1054-
1055-
// Expect a folder, reject files
1056-
if (pathType == 1) {
1057-
if (subPath.endsWith("/")) {
1058-
// Not a file - abort!
1059-
continue;
1060-
}
1061-
}
1062-
1063-
// Expect files, reject folders
1064-
if (pathType == 2) {
1065-
if (!subPath.endsWith("/")) {
1066-
// Not a folder - abort!
1067-
continue;
1068-
}
1069-
}
1070-
1071-
// Finally - all checks passed : add the path
1072-
ret.add(subPath);
1073-
}
1074-
1075-
// // Debugging stuff
1076-
System.out.println( "Filtered Set: "+ConvertJSON.fromObject(ret) );
1077-
1078-
1079-
// Return the filtered set
1080-
return ret;
1081-
}
1082950

1083951
//--------------------------------------------------------------------------
1084952
//

0 commit comments

Comments
 (0)