Throw Exception in checkFileIntegrity on failure
DownloadWorker didn't check the string return value which should detect failed downloads. Throwing (checked) exceptions simplifies error handling in DownloadWorker.
This commit is contained in:
parent
f0df9f94d4
commit
02eddeff81
3 changed files with 13 additions and 22 deletions
|
@ -20,7 +20,7 @@ public final class DirectWeaver extends ByteDataWriter
|
||||||
|
|
||||||
private int size = 0;
|
private int size = 0;
|
||||||
|
|
||||||
public DirectWeaver( StatCoderContext bc, DataBuffers dataBuffers, int lonIdx, int latIdx, int divisor, TagValueValidator wayValidator, WaypointMatcher waypointMatcher, OsmNodesMap hollowNodes ) throws Exception
|
public DirectWeaver( StatCoderContext bc, DataBuffers dataBuffers, int lonIdx, int latIdx, int divisor, TagValueValidator wayValidator, WaypointMatcher waypointMatcher, OsmNodesMap hollowNodes )
|
||||||
{
|
{
|
||||||
super( null );
|
super( null );
|
||||||
int cellsize = 1000000 / divisor;
|
int cellsize = 1000000 / divisor;
|
||||||
|
|
|
@ -35,7 +35,7 @@ final class OsmFile
|
||||||
private int ncaches;
|
private int ncaches;
|
||||||
private int indexsize;
|
private int indexsize;
|
||||||
|
|
||||||
public OsmFile( PhysicalFile rafile, int lonDegree, int latDegree, DataBuffers dataBuffers ) throws Exception
|
public OsmFile( PhysicalFile rafile, int lonDegree, int latDegree, DataBuffers dataBuffers ) throws IOException
|
||||||
{
|
{
|
||||||
this.lonDegree = lonDegree;
|
this.lonDegree = lonDegree;
|
||||||
this.latDegree = latDegree;
|
this.latDegree = latDegree;
|
||||||
|
@ -111,7 +111,7 @@ final class OsmFile
|
||||||
return idx == -1 ? indexsize : posIdx[idx];
|
return idx == -1 ? indexsize : posIdx[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDataInputForSubIdx( int subIdx, byte[] iobuffer ) throws Exception
|
public int getDataInputForSubIdx( int subIdx, byte[] iobuffer ) throws IOException
|
||||||
{
|
{
|
||||||
int startPos = getPosIdx( subIdx - 1 );
|
int startPos = getPosIdx( subIdx - 1 );
|
||||||
int endPos = getPosIdx( subIdx );
|
int endPos = getPosIdx( subIdx );
|
||||||
|
@ -128,7 +128,7 @@ final class OsmFile
|
||||||
}
|
}
|
||||||
|
|
||||||
public MicroCache createMicroCache( int lonIdx, int latIdx, DataBuffers dataBuffers, TagValueValidator wayValidator,
|
public MicroCache createMicroCache( int lonIdx, int latIdx, DataBuffers dataBuffers, TagValueValidator wayValidator,
|
||||||
WaypointMatcher waypointMatcher, boolean reallyDecode, OsmNodesMap hollowNodes ) throws Exception
|
WaypointMatcher waypointMatcher, boolean reallyDecode, OsmNodesMap hollowNodes ) throws IOException
|
||||||
{
|
{
|
||||||
int subIdx = ( latIdx - divisor * latDegree ) * divisor + ( lonIdx - divisor * lonDegree );
|
int subIdx = ( latIdx - divisor * latDegree ) * divisor + ( lonIdx - divisor * lonDegree );
|
||||||
|
|
||||||
|
|
|
@ -31,13 +31,12 @@ final public class PhysicalFile
|
||||||
{
|
{
|
||||||
MicroCache.debug = true;
|
MicroCache.debug = true;
|
||||||
|
|
||||||
String message = checkFileIntegrity( new File( args[0] ) );
|
try {
|
||||||
|
checkFileIntegrity( new File( args[0] ) );
|
||||||
if ( message != null )
|
} catch (IOException e) {
|
||||||
{
|
System.err.println( "************************************" );
|
||||||
System.out.println( "************************************" );
|
e.printStackTrace();
|
||||||
System.out.println( message );
|
System.err.println( "************************************" );
|
||||||
System.out.println( "************************************" );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +45,7 @@ final public class PhysicalFile
|
||||||
*
|
*
|
||||||
* @return the error message if file corrupt, else null
|
* @return the error message if file corrupt, else null
|
||||||
*/
|
*/
|
||||||
public static String checkFileIntegrity( File f )
|
public static String checkFileIntegrity( File f ) throws IOException
|
||||||
{
|
{
|
||||||
PhysicalFile pf = null;
|
PhysicalFile pf = null;
|
||||||
try
|
try
|
||||||
|
@ -66,14 +65,6 @@ final public class PhysicalFile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException iae)
|
|
||||||
{
|
|
||||||
return iae.getMessage();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return e.toString();
|
|
||||||
}
|
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if ( pf != null )
|
if ( pf != null )
|
||||||
|
@ -88,7 +79,7 @@ final public class PhysicalFile
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PhysicalFile( File f, DataBuffers dataBuffers, int lookupVersion, int lookupMinorVersion ) throws Exception
|
public PhysicalFile( File f, DataBuffers dataBuffers, int lookupVersion, int lookupMinorVersion ) throws IOException
|
||||||
{
|
{
|
||||||
fileName = f.getName();
|
fileName = f.getName();
|
||||||
byte[] iobuffer = dataBuffers.iobuffer;
|
byte[] iobuffer = dataBuffers.iobuffer;
|
||||||
|
@ -102,7 +93,7 @@ final public class PhysicalFile
|
||||||
short readVersion = (short)(lv >> 48);
|
short readVersion = (short)(lv >> 48);
|
||||||
if ( i == 0 && lookupVersion != -1 && readVersion != lookupVersion )
|
if ( i == 0 && lookupVersion != -1 && readVersion != lookupVersion )
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException( "lookup version mismatch (old rd5?) lookups.dat="
|
throw new IOException( "lookup version mismatch (old rd5?) lookups.dat="
|
||||||
+ lookupVersion + " " + f. getAbsolutePath() + "=" + readVersion );
|
+ lookupVersion + " " + f. getAbsolutePath() + "=" + readVersion );
|
||||||
}
|
}
|
||||||
fileIndex[i] = lv & 0xffffffffffffL;
|
fileIndex[i] = lv & 0xffffffffffffL;
|
||||||
|
|
Loading…
Reference in a new issue