Changeset d499293


Ignore:
Timestamp:
Jul 14, 2018 5:09:51 PM (23 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
4ff62c2
Parents:
2a0b927
Message:

i2psnark: Recreate deleted files on recheck/reopen (ticket #2125)

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • apps/i2psnark/java/src/org/klomp/snark/Storage.java

    r2a0b927 rd499293  
    789789      if (_torrentFiles.isEmpty())
    790790          throw new IOException("Storage not checked yet");
    791       for (TorrentFile tf : _torrentFiles) {
    792           if (!tf.RAFfile.exists())
    793               throw new IOException("File does not exist: " + tf);
     791      for (int i = 0; i < _torrentFiles.size(); i++) {
     792          TorrentFile tf = _torrentFiles.get(i);
     793          if (!tf.RAFfile.exists()) {
     794              // File should exist when we get here, but could have vanished
     795              List<List<String>> files = metainfo.getFiles();
     796              if (files != null) {
     797                  createFileFromNames(_base, files.get(i), _util.getFilesPublic());
     798              } else {
     799                  if (!_base.createNewFile())
     800                      throw new IOException("File '" + tf.name + "' was deleted, unable to recreate");
     801              }
     802              synchronized(tf) {
     803                  tf.allocateFile();
     804                  // close as we go so we don't run out of file descriptors
     805                  try {
     806                      tf.closeRAF();
     807                  } catch (IOException ioe) {}
     808              }
     809              String msg = "File '" + tf.name + "' was deleted, must be downloaded again";
     810              if (listener != null)
     811                  listener.addMessage(msg);
     812              _log.error(msg);
     813          }
    794814      }
    795815  }
     
    10241044    // The files should all exist as they have been created with zero length by createFilesFromNames()
    10251045    long lengthProgress = 0;
    1026     for (TorrentFile tf : _torrentFiles)
    1027       {
     1046    for (int i = 0; i < _torrentFiles.size(); i++) {
     1047        TorrentFile tf = _torrentFiles.get(i);
    10281048        long length = tf.RAFfile.length();
    10291049        lengthProgress += tf.length;
    1030         if(tf.RAFfile.exists() && length == tf.length)
    1031           {
     1050        boolean exists = tf.RAFfile.exists();
     1051        if (exists && length == tf.length) {
    10321052            if (listener != null)
    10331053              listener.storageAllocated(this, length);
    10341054            _checkProgress.set(0);
    10351055            resume = true; // XXX Could dynamicly check
    1036           }
    1037         else if (length == 0) {
     1056        } else if (length == 0) {
     1057          if (!exists) {
     1058              // File should exist when we get here, but could have vanished
     1059              // and we're now doing a recheck
     1060              List<List<String>> files = metainfo.getFiles();
     1061              if (files != null) {
     1062                  createFileFromNames(_base, files.get(i), _util.getFilesPublic());
     1063              } else {
     1064                  if (!_base.createNewFile())
     1065                      throw new IOException("File '" + tf.name + "' was deleted, unable to recreate");
     1066              }
     1067              String msg = "File '" + tf.name + "' was deleted, must be downloaded again";
     1068              if (listener != null)
     1069                  listener.addMessage(msg);
     1070              _log.error(msg);
     1071          }
    10381072          changed = true;
    10391073          synchronized(tf) {
     
    15071541       *  defrag the file.
    15081542       *
     1543       *  File MUST exist or will throw IOE
     1544       *
    15091545       *  This calls openRAF(); caller must synchronize and call closeRAF().
    15101546       */
  • history.txt

    r2a0b927 rd499293  
     12018-07-14 zzz
     2 * i2psnark: Recreate deleted files on recheck/reopen (ticket #2125)
     3
    142018-07-13 zzz
    25 * i2psnark: Add sequential order option (ticket #2234)
  • router/java/src/net/i2p/router/RouterVersion.java

    r2a0b927 rd499293  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 11;
     21    public final static long BUILD = 12;
    2222
    2323    /** for example "-test" */
Note: See TracChangeset for help on using the changeset viewer.