mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
fix seek error for 0 file size records file
by add extra check for file size = 0 in cleanlast() - (http://mantis.tokeek.de/view.php?id=411)
This commit is contained in:
parent
1f2eba977d
commit
2b8cc5832c
|
@ -399,10 +399,14 @@ public final class Records {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// read entry from the file
|
// read entry from the file
|
||||||
final long endpos = this.raf.length() - this.recordsize;
|
long endpos = this.raf.length() - this.recordsize;
|
||||||
|
if (endpos >= 0) { // prevent seek error for 0 size file
|
||||||
this.raf.seek(endpos);
|
this.raf.seek(endpos);
|
||||||
this.raf.readFully(b, start, this.recordsize);
|
this.raf.readFully(b, start, this.recordsize);
|
||||||
|
} else {
|
||||||
|
endpos = 0;
|
||||||
|
System.arraycopy(this.zero, 0, b, start, this.recordsize);
|
||||||
|
}
|
||||||
// write zero bytes to the cache and to the file
|
// write zero bytes to the cache and to the file
|
||||||
this.raf.seek(endpos);
|
this.raf.seek(endpos);
|
||||||
this.raf.write(this.zero, 0, this.recordsize);
|
this.raf.write(this.zero, 0, this.recordsize);
|
||||||
|
@ -434,6 +438,7 @@ public final class Records {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// shrink file
|
// shrink file
|
||||||
|
if (this.raf.length() > 0) // already 0 length, nothing to shrink (prevent seek io error)
|
||||||
this.raf.setLength(this.raf.length() - this.recordsize);
|
this.raf.setLength(this.raf.length() - this.recordsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user