11package picoded .dstack .core ;
22
33import picoded .core .conv .ArrayConv ;
4+ import picoded .core .conv .ConvertJSON ;
45import picoded .core .file .FileUtil ;
56
67// Java imports
@@ -559,12 +560,26 @@ protected Set<String> backend_filterPathSet(final Set<String> rawSet, final Stri
559560 }
560561 int searchPathLen = searchPath .length ();
561562
563+ // // Debugging stuff
564+ // System.out.println( "#" );
565+ // System.out.println( "searchPath: "+searchPath );
566+ // System.out.println( "searchPathLen: "+searchPathLen );
567+ // System.out.println( "minDepth: "+minDepth );
568+ // System.out.println( "maxDepth: "+maxDepth );
569+ // System.out.println( "pathType: "+pathType );
570+ // System.out.println( ConvertJSON.fromObject(rawSet) );
571+
562572 // Return set
563573 Set <String > ret = new HashSet <>();
564574
565575 // Get the keyset, and iterate it
566576 for (String key : rawSet ) {
567577
578+ // Skip the root folder of a workspace
579+ if ( key .equals ("" ) || key .equals ("/" ) ) {
580+ continue ;
581+ }
582+
568583 // If folder does not match - skip
569584 if (searchPathLen > 0 && !key .startsWith (searchPath )) {
570585 continue ;
@@ -575,32 +590,36 @@ protected Set<String> backend_filterPathSet(final Set<String> rawSet, final Stri
575590
576591 // No filtering is needed, store and continue
577592 if (maxDepth <= 0 && minDepth <= 0 ) {
578- // Does nothing
579- } else {
580- // Lets perform path filtering
581-
582- // Lets filter out the ending "/"
583- String filteredSubPath = subPath ;
584- if (filteredSubPath .endsWith ("/" )) {
585- filteredSubPath = filteredSubPath .substring (0 , filteredSubPath .length ());
586- }
587-
588- // Split and count
589- String [] splitSubPath = filteredSubPath .split ("/" );
590- int subPathLength = (filteredSubPath .length () <= 0 ) ? 0 : splitSubPath .length ;
591-
592- // Check min depth - skip key if check failed
593- if (subPathLength < minDepth ) {
594- continue ;
595- }
596-
597- // Check max depth - skip key if check failed
598- if (subPathLength > maxDepth ) {
599- continue ;
600- }
593+ // Does no checks, add and continue
594+ ret .add (subPath );
595+ continue ;
596+ }
597+
598+ // Lets perform path filtering
599+ // ---
600+
601+ // Lets filter out the ending "/"
602+ String filteredSubPath = subPath ;
603+ if (filteredSubPath .endsWith ("/" )) {
604+ filteredSubPath = filteredSubPath .substring (0 , filteredSubPath .length () - 1 );
605+ }
606+
607+ // Split and count
608+ String [] splitSubPath = filteredSubPath .split ("/" );
609+ int subPathLength = (filteredSubPath .length () <= 0 ) ? 0 : splitSubPath .length ;
610+
611+ // Check min depth - skip key if check failed
612+ if (minDepth > 0 && subPathLength < minDepth ) {
613+ continue ;
614+ }
615+
616+ // Check max depth - skip key if check failed
617+ if (maxDepth > 0 && subPathLength > maxDepth ) {
618+ continue ;
601619 }
602620
603621 // Alrighto - lets check file / folder type - and add it in
622+ // ---
604623
605624 // Ignore empty, or root path
606625 if (subPath .isEmpty () || subPath .equals ("/" )) {
@@ -627,6 +646,10 @@ protected Set<String> backend_filterPathSet(final Set<String> rawSet, final Stri
627646 ret .add (subPath );
628647 }
629648
649+ // // Debugging stuff
650+ // System.out.println( "Filtered Set" );
651+ // System.out.println( ConvertJSON.fromObject(ret) );
652+
630653 // Return the filtered set
631654 return ret ;
632655 }
0 commit comments