Skip to content

Commit

Permalink
CTcache: fix bug with gzip filepath parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
mjm-cycronix committed Apr 3, 2018
1 parent ad75c4c commit 750b6da
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions JavaCode/CTlib/src/main/java/cycronix/ctlib/CTcache.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ public String chan2key(String chan) {
// utility class to store time/folder pairs
// NOTE: the size of this class has string influence on size of CTFileCache for large CTdata archives

private String tmpdir = System.getProperty("java.io.tmpdir"); // for decode ref

public TimeFolder newTimeFolder(CTFile file, double time) {
return new TimeFolder(file, time);
}
Expand All @@ -256,7 +258,7 @@ public class TimeFolder implements Comparable<TimeFolder> {
private byte[] myPathBytes=null;
private double folderTime;
private byte[] myZipFileBytes=null;

public TimeFolder(CTFile file, double time) {
String myPath = file.getMyPath();
folderTime = time;
Expand All @@ -266,8 +268,10 @@ public TimeFolder(CTFile file, double time) {
String trimZip = myZipFile.replace(".zip", File.separator); // oops this was broke on Windows
myPath = myPath.replace(trimZip, ""); // shorten myPath (saves space)
myZipFile = myZipFile.replace(".zip", "");
myZipFile = myZipFile.replace(rootFolder, ""); // stingy
}
// System.err.println("myZipFile: "+myZipFile+", rootFolder: "+rootFolder+", startswith: "+(myZipFile.startsWith(rootFolder)));
if(myZipFile.startsWith(rootFolder))
myZipFile = myZipFile.replace(rootFolder, ""); // stingy
}
else myPath = myPath.replace(rootFolder, "");

CTFileCache.put(myPath, file); // stock up FileCache here?
Expand All @@ -283,10 +287,20 @@ public CTFile getCTFile() {
// System.err.println("Decode: myPath: "+myPath+", myZipFile; "+myZipFile);

try {
if(myZipFile==null) return cachedCTFile(rootFolder + myPath, null);
else return cachedCTFile(myPath, rootFolder + myZipFile+".zip");
CTFile ctfile=null;
if(myZipFile==null) ctfile = cachedCTFile(rootFolder + myPath, null);
// else ctfile = cachedCTFile(myPath, rootFolder + myZipFile+".zip");
else {
if(myZipFile.startsWith(tmpdir))
ctfile = cachedCTFile(myPath, myZipFile+".zip"); // if absolute path presume gzip/temp folder?
else
ctfile = cachedCTFile(myPath, rootFolder + myZipFile+".zip");
}

// System.err.println("+++++++CTfile: "+ctfile);
return ctfile;
} catch(Exception e) {
// System.err.println("TimeFolder getCTFile exception: "+e);
System.err.println("TimeFolder getCTFile exception: "+e);
return null;
}
}
Expand Down

0 comments on commit 750b6da

Please sign in to comment.