Changeset c6896c44


Ignore:
Timestamp:
Jun 20, 2015 10:03:47 AM (5 years ago)
Author:
dg2-new <dg2-new@…>
Branches:
master
Children:
699d550
Parents:
1b2d4c7
Message:

I2PSnark: Auto-start now only starts torrents which were running at shutdown (#766)

Files:
2 edited

Legend:

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

    r1b2d4c7 rc6896c44  
    9090    public static final String PROP_DIR = "i2psnark.dir";
    9191    private static final String PROP_META_PREFIX = "i2psnark.zmeta.";
     92    private static final String PROP_META_RUNNING = "running";
    9293    private static final String PROP_META_STAMP = "stamp";
    9394    private static final String PROP_META_BASE = "base";
     
    12711272        }
    12721273        // ok, snark created, now lets start it up or configure it further
    1273         if (!dontAutoStart && shouldAutoStart()) {
     1274        Properties config = getConfig(torrent);
     1275        boolean running = Boolean.parseBoolean(config.getProperty(PROP_META_RUNNING));
     1276        // Were we running last time?
     1277        if (!dontAutoStart && shouldAutoStart() && running) {
    12741278            torrent.startTorrent();
    12751279            addMessage(_("Torrent added and started: \"{0}\"", torrent.getBaseName()));
     
    14321436            }
    14331437            // so addTorrent won't recheck
    1434             saveTorrentStatus(metainfo, bitfield, null, baseFile, true, 0); // no file priorities
     1438            saveTorrentStatus(metainfo, bitfield, null, baseFile, true, 0, snark.isStopped()); // no file priorities
    14351439            try {
    14361440                locked_writeMetaInfo(metainfo, filename, areFilesPublic());
     
    16271631        saveTorrentStatus(meta, storage.getBitField(), storage.getFilePriorities(),
    16281632                          storage.getBase(), storage.getPreserveFileNames(),
    1629                           snark.getUploaded());
     1633                          snark.getUploaded(), snark.isStopped());
    16301634    }
    16311635
     
    16421646     */
    16431647    private void saveTorrentStatus(MetaInfo metainfo, BitField bitfield, int[] priorities,
    1644                                    File base, boolean preserveNames, long uploaded) {
     1648                                   File base, boolean preserveNames, long uploaded, boolean stopped) {
    16451649        synchronized (_configLock) {
    1646             locked_saveTorrentStatus(metainfo, bitfield, priorities, base, preserveNames, uploaded);
     1650            locked_saveTorrentStatus(metainfo, bitfield, priorities, base, preserveNames, uploaded, stopped);
    16471651        }
    16481652    }
    16491653
    16501654    private void locked_saveTorrentStatus(MetaInfo metainfo, BitField bitfield, int[] priorities,
    1651                                           File base, boolean preserveNames, long uploaded) {
     1655                                          File base, boolean preserveNames, long uploaded, boolean stopped) {
    16521656        byte[] ih = metainfo.getInfoHash();
    16531657        String bfs;
     
    16581662          bfs = Base64.encode(bf);
    16591663        }
     1664        boolean running = !stopped;
    16601665        Properties config = getConfig(ih);
    16611666        config.setProperty(PROP_META_STAMP, Long.toString(System.currentTimeMillis()));
     
    16631668        config.setProperty(PROP_META_PRESERVE_NAMES, Boolean.toString(preserveNames));
    16641669        config.setProperty(PROP_META_UPLOADED, Long.toString(uploaded));
     1670        config.setProperty(PROP_META_RUNNING, Boolean.toString(running));
    16651671        if (base != null)
    16661672            config.setProperty(PROP_META_BASE, base.getAbsolutePath());
     
    19901996        if (meta != null && storage != null)
    19911997            saveTorrentStatus(meta, storage.getBitField(), storage.getFilePriorities(),
    1992                               storage.getBase(), storage.getPreserveFileNames(), snark.getUploaded());
     1998                              storage.getBase(), storage.getPreserveFileNames(), snark.getUploaded(),
     1999                              snark.isStopped());
    19932000    }
    19942001   
     
    20132020            }
    20142021            saveTorrentStatus(meta, storage.getBitField(), null,
    2015                               storage.getBase(), storage.getPreserveFileNames(), 0);
     2022                              storage.getBase(), storage.getPreserveFileNames(), 0,
     2023                              snark.isStopped());
    20162024            // temp for addMessage() in case canonical throws
    20172025            String name = storage.getBaseName();
     
    23512359                    addMessage(_("Stopping all torrents and closing the I2P tunnel."));
    23522360                count++;
     2361                saveTorrentStatus(snark);
    23532362                if (finalShutdown)
    23542363                    snark.stopTorrent(true);
  • history.txt

    r1b2d4c7 rc6896c44  
     12015-06-20 dg
     2 * I2PSnark: Auto-start now only starts torrents which were running at shutdown (#766)
     3
    142015-06-19 zzz
    25 * I2CP: Fix simple session lookups, broken in prop
Note: See TracChangeset for help on using the changeset viewer.