More work to make remote downloadable indices work.
authorJan Lahoda <jlahoda@netbeans.org>
Mon, 26 Sep 2011 17:33:33 +0200
changeset 6932f0e6e47d255
parent 692 4853f67582ce
child 694 59f50e037ca0
More work to make remote downloadable indices work.
remoting/server/indexer/impl/src/org/netbeans/modules/jackpot30/backend/impl/OptionProcessorImpl.java
     1.1 --- a/remoting/server/indexer/impl/src/org/netbeans/modules/jackpot30/backend/impl/OptionProcessorImpl.java	Mon Sep 26 14:05:06 2011 +0200
     1.2 +++ b/remoting/server/indexer/impl/src/org/netbeans/modules/jackpot30/backend/impl/OptionProcessorImpl.java	Mon Sep 26 17:33:33 2011 +0200
     1.3 @@ -211,7 +211,7 @@
     1.4              out.write(("{ \"displayName\": \"" + categoryName + "\" }").getBytes("UTF-8"));
     1.5  
     1.6              for (FileObject s : cacheFolder.getChildren()) {
     1.7 -                if (!s.isFolder() || !s.getNameExt().startsWith("s") || !containsAFile(s)) continue;
     1.8 +                if (!s.isFolder() || !s.getNameExt().startsWith("s") || s.getChildren().length == 0) continue;
     1.9  
    1.10                  JarOutputStream local = null;
    1.11                  try {
    1.12 @@ -219,7 +219,7 @@
    1.13  
    1.14                      local = new JarOutputStream(out);
    1.15  
    1.16 -                    pack(local, s, s.getNameExt(), new StringBuilder(categoryId));
    1.17 +                    pack(local, s, "", new StringBuilder(""));
    1.18                  } finally {
    1.19                      if (local != null) {
    1.20                          local.finish();
    1.21 @@ -324,14 +324,13 @@
    1.22          if (!first) relPath.append("/");
    1.23          relPath.append(name);
    1.24  
    1.25 -        for (FileObject c : index.getChildren()) {
    1.26 -            if (first && c.getNameExt().equals("segments")) continue;
    1.27 -            pack(target, c, c.getNameExt(), relPath);
    1.28 +        boolean data = index.isData();
    1.29 +
    1.30 +        if (relPath.length() > 0) {
    1.31 +            target.putNextEntry(new ZipEntry(relPath.toString() + (data ? "" : "/")));
    1.32          }
    1.33  
    1.34 -        if (index.isData()) {
    1.35 -            target.putNextEntry(new ZipEntry(relPath.toString()));
    1.36 -
    1.37 +        if (data) {
    1.38              InputStream in = index.getInputStream();
    1.39  
    1.40              try {
    1.41 @@ -341,16 +340,12 @@
    1.42              }
    1.43          }
    1.44  
    1.45 +        for (FileObject c : index.getChildren()) {
    1.46 +            if (first && c.getNameExt().equals("segments")) continue;
    1.47 +            pack(target, c, c.getNameExt(), relPath);
    1.48 +        }
    1.49 +
    1.50          relPath.delete(len, relPath.length());
    1.51      }
    1.52  
    1.53 -    private static boolean containsAFile(FileObject root) {
    1.54 -        if (root.isData()) return true;
    1.55 -
    1.56 -        for (FileObject c : root.getChildren()) {
    1.57 -            if (containsAFile(c)) return true;
    1.58 -        }
    1.59 -
    1.60 -        return false;
    1.61 -    }
    1.62  }