2005-12-16 jrandom

* Try to run a torrent in readonly mode if we can't write to the file, and
      handle failures a little more gracefully (thanks polecat!)
This commit is contained in:
jrandom
2005-12-16 11:01:20 +00:00
committed by zzz
parent 7726bd1a5c
commit 6f424fa751
2 changed files with 14 additions and 3 deletions

View File

@ -256,6 +256,9 @@ public class Storage
rafs = new RandomAccessFile[1];
names = new String[1];
lengths[0] = metainfo.getTotalLength();
if (base.exists() && !base.canWrite()) // hope we can get away with this, if we are only seeding...
rafs[0] = new RandomAccessFile(base, "r");
else
rafs[0] = new RandomAccessFile(base, "rw");
names[0] = base.getName();
}
@ -277,6 +280,9 @@ public class Storage
File f = createFileFromNames(base, (List)files.get(i));
lengths[i] = ((Long)ls.get(i)).longValue();
total += lengths[i];
if (f.exists() && !f.canWrite()) // see above re: only seeding
rafs[i] = new RandomAccessFile(f, "r");
else
rafs[i] = new RandomAccessFile(f, "rw");
names[i] = f.getName();
}
@ -402,6 +408,7 @@ public class Storage
*/
public void close() throws IOException
{
if (rafs == null) return;
for (int i = 0; i < rafs.length; i++)
{
try {

View File

@ -1,4 +1,8 @@
$Id: history.txt,v 1.357 2005/12/15 22:00:48 jrandom Exp $
$Id: history.txt,v 1.358 2005/12/16 03:24:22 jrandom Exp $
2005-12-16 jrandom
* Try to run a torrent in readonly mode if we can't write to the file, and
handle failures a little more gracefully (thanks polecat!)
2005-12-16 jrandom
* Refuse torrents with too many files (128), avoiding ulimit errors.