Skip to content

Commit

Permalink
v1.1: fixed NullPtrExceptions when syncing/deleting empty tiles
Browse files Browse the repository at this point in the history
  • Loading branch information
open744 committed Aug 14, 2015
1 parent 3355683 commit 816e47a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
2 changes: 1 addition & 1 deletion MapFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ public String getToolTipText(MouseEvent e) {
if (d.terrain) {
txt += " +Terr";
File f = d.dir_terr;
if (f != null) {
if (f != null & f.exists()) {
int count = 0;
for (String i : f.list()) {
if (i.endsWith(".btg.gz")) {
Expand Down
53 changes: 28 additions & 25 deletions Svn.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,17 @@ public void handleDirEntry(SVNDirEntry e)
private void printStats(String path)
{
try {
SVNURL url = SVNURL.parseURIDecoded(urlBase + path);
SVNURL url = SVNURL.parseURIEncoded(urlBase + path);
synccount = syncsize = 0;
logClient.doList(url, SVNRevision.HEAD, SVNRevision.HEAD, false, true, this);
System.out.printf("%s/%d items (%d bytes)... ", path, synccount, syncsize);
} catch (SVNException e) { }
} catch (SVNException e) {
SVNErrorMessage em = e.getErrorMessage();
if (em.getErrorCode().getCode() == 160013)
System.err.printf("%s not found\n", path);
else
System.err.printf("doList: %s\n", e.getMessage());
}
}

/*
Expand All @@ -145,7 +151,7 @@ private void checkout(String name) {

// make sure the working copy root is valid
try {
verifyRoot(new File(pathBase), SVNURL.parseURIDecoded(urlBase));
verifyRoot(new File(pathBase), SVNURL.parseURIEncoded(urlBase));
} catch (SVNException e) {
}

Expand All @@ -160,20 +166,21 @@ private void checkout(String name) {

printStats(node);
long rev = updateNode(f);
if (rev > 0)
System.out.printf("updated to r%d.\n", rev);

TerraMaster.addScnMapTile(TerraMaster.mapScenery, f, ntype[i]);

invokeLater(2); // update progressBar

// look for airport codes among the newly sync'd Terrain files
if (i == 0) {
String[] apt = findAirports(f);
for (int j = 0; j < apt.length; ++j)
invokeLater(3); // extend progressBar

syncAirports(apt);
if (rev > 0) {
System.out.printf("updated to r%d.\n", rev);
TerraMaster.addScnMapTile(TerraMaster.mapScenery, f, ntype[i]);

// look for airport codes among the newly sync'd Terrain files
if (i == 0 & f.exists()) {
String[] apt = findAirports(f);
if (apt != null) {
for (int j = 0; j < apt.length; ++j)
invokeLater(3); // extend progressBar
syncAirports(apt);
}
}
}

} catch (SVNException x) {
Expand All @@ -183,7 +190,7 @@ private void checkout(String name) {
//if (em.getErrorCode().getCode() != 160013)
System.out.println(x.getMessage());
// 155004 unfinished work items, need svn cleanup
} //catch (Exception x) { System.out.println(x); }
} catch (Exception x) { System.out.println(x); }

}
}
Expand All @@ -207,20 +214,16 @@ private void syncAirports(String[] names)
{
long rev;

if (names == null) return;

for (String i : names) {
String node = String.format("Airports/%c/%c/%c/",
String node = String.format("Airports/%c/%c/%c",
i.charAt(0), i.charAt(1), i.charAt(2));
File f = new File(pathBase + node);

try {
printStats(node);
rev = updateNode(f);
if (rev > 0) System.out.printf("updated to r%d.\n", rev);

invokeLater(2); // update progressBar

if (rev > 0) System.out.printf("updated to r%d.\n", rev);
} catch (SVNException x) {
System.out.println(x.getMessage());
}
Expand All @@ -235,9 +238,8 @@ private void syncModels(String name)

File f = new File(pathBase + "Models/" + name);
long rev = updateNode(f);
if (rev > 0) System.out.printf("updated to r%d.\n", rev);

invokeLater(2); // update progressBar
if (rev > 0) System.out.printf("updated to r%d.\n", rev);
} catch (SVNException x) {
System.out.println(x.getMessage());
}
Expand All @@ -249,7 +251,7 @@ private void syncModels()
File d;

try {
verifyRoot(new File(pathBase), SVNURL.parseURIDecoded(urlBase));
verifyRoot(new File(pathBase), SVNURL.parseURIEncoded(urlBase));

d = new File(pathBase + "Models/");

Expand Down Expand Up @@ -295,6 +297,7 @@ public void cancel()

private void deltree(File d)
{
if (!d.exists()) return;
for (File f : d.listFiles()) {
if (f.isDirectory())
deltree(f);
Expand Down

0 comments on commit 816e47a

Please sign in to comment.