(zzz) 02-28 i2psnark file reopen cleanup

This commit is contained in:
zzz
2007-03-01 02:29:11 +00:00
committed by zzz
parent a3c64a9ba3
commit ce50efa60c
3 changed files with 24 additions and 9 deletions

View File

@ -76,7 +76,6 @@ public class Storage
throws IOException throws IOException
{ {
this.listener = listener; this.listener = listener;
// Create names, rafs and lengths arrays. // Create names, rafs and lengths arrays.
getFiles(baseFile); getFiles(baseFile);
@ -132,13 +131,14 @@ public class Storage
// Creates piece hases for a new storage. // Creates piece hases for a new storage.
public void create() throws IOException public void create() throws IOException
{ {
if (true) { // if (true) {
fast_digestCreate(); fast_digestCreate();
} else { // } else {
orig_digestCreate(); // orig_digestCreate();
} // }
} }
/*
private void orig_digestCreate() throws IOException { private void orig_digestCreate() throws IOException {
// Calculate piece_hashes // Calculate piece_hashes
MessageDigest digest = null; MessageDigest digest = null;
@ -174,6 +174,7 @@ public class Storage
// Reannounce to force recalculating the info_hash. // Reannounce to force recalculating the info_hash.
metainfo = metainfo.reannounce(metainfo.getAnnounce()); metainfo = metainfo.reannounce(metainfo.getAnnounce());
} }
*/
private void fast_digestCreate() throws IOException { private void fast_digestCreate() throws IOException {
// Calculate piece_hashes // Calculate piece_hashes
@ -368,7 +369,7 @@ public class Storage
int size = files.size(); int size = files.size();
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
{ {
File f = createFileFromNames(base, (List)files.get(i)); File f = getFileFromNames(base, (List)files.get(i));
if (!f.exists()) if (!f.exists())
throw new IOException("Could not reopen file " + f); throw new IOException("Could not reopen file " + f);
if (!f.canWrite()) // see above re: only seeding if (!f.canWrite()) // see above re: only seeding
@ -415,6 +416,17 @@ public class Storage
return f; return f;
} }
private File getFileFromNames(File base, List names) throws IOException
{
Iterator it = names.iterator();
while (it.hasNext())
{
String name = filterName((String)it.next());
base = new File(base, name);
}
return base;
}
private void checkCreateFiles() throws IOException private void checkCreateFiles() throws IOException
{ {
// Whether we are resuming or not, // Whether we are resuming or not,

View File

@ -1,4 +1,7 @@
$Id: history.txt,v 1.551 2007-02-15 18:25:04 jrandom Exp $ $Id: history.txt,v 1.552 2007-02-28 21:22:16 zzz Exp $
2007-02-28 zzz
* i2psnark: File reopen cleanup
2007-02-28 zzz 2007-02-28 zzz
* i2psnark: Add peer details to web page * i2psnark: Add peer details to web page

View File

@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
* *
*/ */
public class RouterVersion { public class RouterVersion {
public final static String ID = "$Revision: 1.487 $ $Date: 2007-02-15 18:25:06 $"; public final static String ID = "$Revision: 1.488 $ $Date: 2007-02-28 21:22:14 $";
public final static String VERSION = "0.6.1.27"; public final static String VERSION = "0.6.1.27";
public final static long BUILD = 1; public final static long BUILD = 2;
public static void main(String args[]) { public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION + "-" + BUILD); System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
System.out.println("Router ID: " + RouterVersion.ID); System.out.println("Router ID: " + RouterVersion.ID);