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:
@ -256,6 +256,9 @@ public class Storage
|
|||||||
rafs = new RandomAccessFile[1];
|
rafs = new RandomAccessFile[1];
|
||||||
names = new String[1];
|
names = new String[1];
|
||||||
lengths[0] = metainfo.getTotalLength();
|
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");
|
rafs[0] = new RandomAccessFile(base, "rw");
|
||||||
names[0] = base.getName();
|
names[0] = base.getName();
|
||||||
}
|
}
|
||||||
@ -277,6 +280,9 @@ public class Storage
|
|||||||
File f = createFileFromNames(base, (List)files.get(i));
|
File f = createFileFromNames(base, (List)files.get(i));
|
||||||
lengths[i] = ((Long)ls.get(i)).longValue();
|
lengths[i] = ((Long)ls.get(i)).longValue();
|
||||||
total += lengths[i];
|
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");
|
rafs[i] = new RandomAccessFile(f, "rw");
|
||||||
names[i] = f.getName();
|
names[i] = f.getName();
|
||||||
}
|
}
|
||||||
@ -402,6 +408,7 @@ public class Storage
|
|||||||
*/
|
*/
|
||||||
public void close() throws IOException
|
public void close() throws IOException
|
||||||
{
|
{
|
||||||
|
if (rafs == null) return;
|
||||||
for (int i = 0; i < rafs.length; i++)
|
for (int i = 0; i < rafs.length; i++)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
@ -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
|
2005-12-16 jrandom
|
||||||
* Refuse torrents with too many files (128), avoiding ulimit errors.
|
* Refuse torrents with too many files (128), avoiding ulimit errors.
|
||||||
|
Reference in New Issue
Block a user