Changeset 37597b8


Ignore:
Timestamp:
Sep 16, 2015 2:21:02 PM (4 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
3d533a40
Parents:
addc9c5
Message:

Build:

  • Include geoip in update files for next release
  • Add created-by string to release torrents

i2psnark:

  • Store torrent added and completed times in config files, display on details page
  • Display dates on details page in local time zone
  • Add metainfo creation command line support for created-by string
Files:
5 edited

Legend:

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

    raddc9c5 r37597b8  
    7575   *  @param lengths null for single-file torrent
    7676   *  @param announce_list may be null
     77   *  @param created_by may be null
    7778   */
    7879  MetaInfo(String announce, String name, String name_utf8, List<List<String>> files, List<Long> lengths,
    7980           int piece_length, byte[] piece_hashes, long length, boolean privateTorrent,
    80            List<List<String>> announce_list)
     81           List<List<String>> announce_list, String created_by)
    8182  {
    8283    this.announce = announce;
     
    9293    this.announce_list = announce_list;
    9394    this.comment = null;
    94     this.created_by = null;
     95    this.created_by = created_by;
    9596    this.creation_date = I2PAppContext.getGlobalContext().clock().now();
    9697
  • apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java

    raddc9c5 r37597b8  
    9797    private static final String PROP_META_PRESERVE_NAMES = "preserveFileNames";
    9898    private static final String PROP_META_UPLOADED = "uploaded";
     99    private static final String PROP_META_ADDED = "added";
     100    private static final String PROP_META_COMPLETED = "completed";
    99101    //private static final String PROP_META_BITFIELD_SUFFIX = ".bitfield";
    100102    //private static final String PROP_META_PRIORITY_SUFFIX = ".priority";
     
    16241626        return 0;
    16251627    }
     1628
     1629    /**
     1630     * Get setting for a torrent from the config file.
     1631     * @return non-null, rv[0] is added time or 0; rv[1] is completed time or 0
     1632     * @since 0.9.23
     1633     */
     1634    public long[] getSavedAddedAndCompleted(Snark snark) {
     1635        long[] rv = new long[2];
     1636        Properties config = getConfig(snark);
     1637        if (config != null) {
     1638            try {
     1639                rv[0] = Long.parseLong(config.getProperty(PROP_META_ADDED));
     1640            } catch (NumberFormatException nfe) {}
     1641            try {
     1642                rv[1] = Long.parseLong(config.getProperty(PROP_META_COMPLETED));
     1643            } catch (NumberFormatException nfe) {}
     1644        }
     1645        return rv;
     1646    }
    16261647   
    16271648    /**
     
    16621683                                          File base, boolean preserveNames, long uploaded, boolean stopped) {
    16631684        byte[] ih = metainfo.getInfoHash();
     1685        Properties config = getConfig(ih);
     1686        String now = Long.toString(System.currentTimeMillis());
     1687        config.setProperty(PROP_META_STAMP, now);
     1688        if (config.getProperty(PROP_META_ADDED) == null)
     1689            config.setProperty(PROP_META_ADDED, now);
    16641690        String bfs;
    16651691        if (bitfield.complete()) {
    16661692          bfs = ".";
     1693          if (config.getProperty(PROP_META_COMPLETED) == null)
     1694              config.setProperty(PROP_META_COMPLETED, now);
    16671695        } else {
    16681696          byte[] bf = bitfield.getFieldBytes();
    16691697          bfs = Base64.encode(bf);
    1670         }
    1671         boolean running = !stopped;
    1672         Properties config = getConfig(ih);
    1673         config.setProperty(PROP_META_STAMP, Long.toString(System.currentTimeMillis()));
     1698          config.remove(PROP_META_COMPLETED);
     1699        }
    16741700        config.setProperty(PROP_META_BITFIELD, bfs);
    16751701        config.setProperty(PROP_META_PRESERVE_NAMES, Boolean.toString(preserveNames));
    16761702        config.setProperty(PROP_META_UPLOADED, Long.toString(uploaded));
     1703        boolean running = !stopped;
    16771704        config.setProperty(PROP_META_RUNNING, Boolean.toString(running));
    16781705        if (base != null)
  • apps/i2psnark/java/src/org/klomp/snark/Storage.java

    raddc9c5 r37597b8  
    4040import java.util.concurrent.atomic.AtomicInteger;
    4141
     42import gnu.getopt.Getopt;
     43
    4244import net.i2p.I2PAppContext;
    4345import net.i2p.crypto.SHA1;
     
    124126   * @param announce may be null
    125127   * @param listener may be null
     128   * @param created_by may be null
    126129   * @throws IOException when creating and/or checking files fails.
    127130   */
    128131  public Storage(I2PSnarkUtil util, File baseFile, String announce,
    129132                 List<List<String>> announce_list,
     133                 String created_by,
    130134                 boolean privateTorrent, StorageListener listener)
    131135    throws IOException
     
    196200    metainfo = new MetaInfo(announce, baseFile.getName(), null, files,
    197201                            lengthsList, piece_size, piece_hashes, total, privateTorrent,
    198                             announce_list);
     202                            announce_list, created_by);
    199203
    200204  }
     
    13741378   */
    13751379  public static void main(String[] args) {
    1376       if (args.length < 1 || args.length > 2) {
    1377           System.err.println("Usage: Storage file-or-dir [announceURL]");
     1380      boolean error = false;
     1381      String created_by = null;
     1382      String announce = null;
     1383      Getopt g = new Getopt("Storage", args, "a:c:");
     1384      try {
     1385          int c;
     1386          while ((c = g.getopt()) != -1) {
     1387            switch (c) {
     1388              case 'a':
     1389                  announce = g.getOptarg();
     1390                  break;
     1391
     1392              case 'c':
     1393                  created_by = g.getOptarg();
     1394                  break;
     1395
     1396              case '?':
     1397              case ':':
     1398              default:
     1399                  error = true;
     1400                  break;
     1401            }  // switch
     1402          } // while
     1403      } catch (Exception e) {
     1404          e.printStackTrace();
     1405          error = true;
     1406      }
     1407      if (error || args.length - g.getOptind() != 1) {
     1408          System.err.println("Usage: Storage [-a announceURL] [-c created-by] file-or-dir");
    13781409          System.exit(1);
    13791410      }
    1380       File base = new File(args[0]);
    1381       String announce = args.length == 2 ? args[1] : null;
     1411      File base = new File(args[g.getOptind()]);
    13821412      I2PAppContext ctx = I2PAppContext.getGlobalContext();
    13831413      I2PSnarkUtil util = new I2PSnarkUtil(ctx);
     
    13851415      FileOutputStream out = null;
    13861416      try {
    1387           Storage storage = new Storage(util, base, announce, null, false, null);
     1417          Storage storage = new Storage(util, base, announce, null, created_by, false, null);
    13881418          MetaInfo meta = storage.getMetaInfo();
    13891419          file = new File(storage.getBaseName() + ".torrent");
  • apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java

    raddc9c5 r37597b8  
    1919import java.util.Map;
    2020import java.util.Set;
     21import java.util.TimeZone;
    2122import java.util.TreeMap;
    2223
     
    12311232                        // TODO thread it for big torrents, perhaps a la FetchAndAdd
    12321233                        boolean isPrivate = _manager.getPrivateTrackers().contains(announceURL);
    1233                         Storage s = new Storage(_manager.util(), baseFile, announceURL, announceList, isPrivate, null);
     1234                        Storage s = new Storage(_manager.util(), baseFile, announceURL, announceList, null, isPrivate, null);
    12341235                        s.close(); // close the files... maybe need a way to pass this Storage to addTorrent rather than starting over
    12351236                        MetaInfo info = s.getMetaInfo();
     
    27642765                }
    27652766                long dat = meta.getCreationDate();
     2767                SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm");
     2768                String systemTimeZone = _context.getProperty("i2p.systemTimeZone");
     2769                if (systemTimeZone != null)
     2770                    fmt.setTimeZone(TimeZone.getTimeZone(systemTimeZone));
    27662771                if (dat > 0) {
    2767                     String date = (new SimpleDateFormat("yyyy-MM-dd HH:mm")).format(new Date(dat));
     2772                    String date = fmt.format(new Date(dat));
    27682773                    buf.append("<tr><td>");
    27692774                    toThemeImg(buf, "details");
    27702775                    buf.append(" <b>")
    27712776                       .append(_("Created")).append(":</b> ")
    2772                        .append(date).append(" UTC")
     2777                       .append(date)
    27732778                       .append("</td></tr>\n");
    27742779                }
     
    27822787                       .append(_("Created By")).append(":</b> ")
    27832788                       .append(DataHelper.stripHTML(cby))
     2789                       .append("</td></tr>\n");
     2790                }
     2791                long[] dates = _manager.getSavedAddedAndCompleted(snark);
     2792                if (dates[0] > 0) {
     2793                    String date = fmt.format(new Date(dates[0]));
     2794                    buf.append("<tr><td>");
     2795                    toThemeImg(buf, "details");
     2796                    buf.append(" <b>")
     2797                       .append(_("Added")).append(":</b> ")
     2798                       .append(date)
     2799                       .append("</td></tr>\n");
     2800                }
     2801                if (dates[1] > 0) {
     2802                    String date = fmt.format(new Date(dates[1]));
     2803                    buf.append("<tr><td>");
     2804                    toThemeImg(buf, "details");
     2805                    buf.append(" <b>")
     2806                       .append(_("Completed")).append(":</b> ")
     2807                       .append(date)
    27842808                       .append("</td></tr>\n");
    27852809                }
  • build.xml

    raddc9c5 r37597b8  
    101101                    <pathelement location="build/i2psnark.jar" />
    102102                </classpath>
     103                <arg value="-a" />
     104                <arg value="http://tracker2.postman.i2p/announce.php" />
     105                <arg value="-c" />
     106                <arg value="${build.built-by}" />
    103107                <arg value="@{file}" />
    104                 <arg value="http://tracker2.postman.i2p/announce.php" />
    105108            </java>
    106109        </sequential>
     
    17641767<!--
    17651768    <target name="release" depends="distclean, updaterWithJettyFixesAndJbigi , updater200WithJettyFixes, preppkg, installer, getReleaseNumber" >
     1769-->
    17661770    <target name="release" depends="verifyReleaseBuildNumbers, -pre-release, distclean, testscripts, updaterWithJettyAndGeoIPRepack, updater200WithJettyAndGeoIP, delete-j6-update, installer-nowindows, delete-nonwindows, installer-windows">
     1771<!--
     1772    <target name="release" depends="verifyReleaseBuildNumbers, -pre-release, distclean, testscripts, updaterWithJettyRepack, updater200WithJetty, delete-j6-update, installer-nowindows, delete-nonwindows, installer-windows">
    17671773-->
    1768     <target name="release" depends="verifyReleaseBuildNumbers, -pre-release, distclean, testscripts, updaterWithJettyRepack, updater200WithJetty, delete-j6-update, installer-nowindows, delete-nonwindows, installer-windows">
    17691774        <echo message="New version number is ${release.number}" />
    17701775        <copy file="i2pupdate.zip" tofile="i2pupdate_${release.number}.zip" />
Note: See TracChangeset for help on using the changeset viewer.