Changeset 13807
- Timestamp:
- Jan 19, 2013, 8:43:26 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/extras/rpc-spec.txt
r13787 r13807 407 407 Request arguments: 408 408 409 string | value type & description 410 ---------------------------+------------------------------------------------- 411 "ids" | array torrent list, as described in 3.1 412 "location" | string the new torrent location 413 "move" | boolean if true, move from previous location. 414 | otherwise, search "location" for files 415 | (default: false) 409 string | value type & description 410 ---------------------------------+------------------------------------------------- 411 "ids" | array torrent list, as described in 3.1 412 "location" | string the new torrent location 413 "move" | boolean if true, move from previous location. 414 | otherwise, search "location" for files 415 | (default: false) 416 417 Response arguments: none 418 419 420 3.7. Renaming a Torrent's Path 421 422 Method name: "torrent-rename-path" 423 424 For more information on the use of this function, see the 425 transmission.h documentation of tr_torrentRenamePath() 426 427 Request arguments: 428 429 string | value type & description 430 ---------------------------------+------------------------------------------------- 431 "ids" | array the torrent torrent list, as described in 3.1 432 | (though, this function doesn't make sense for >1 torrent) 433 "path" | string the path to the file or folder that will be renamed 434 "name" | string the file or folder's new name 416 435 417 436 Response arguments: none … … 582 601 The following changes have been made to the RPC interface: 583 602 584 RPC | Release | Backwards | | 585 Vers. | Version | Compat? | Method | Description 586 ------+---------+-----------+----------------+------------------------------- 587 1 | 1.30 | n/a | n/a | Initial version 588 ------+---------+-----------+----------------+------------------------------- 589 2 | 1.34 | yes | torrent-get | new arg "peers" 590 ------+---------+-----------+----------------+------------------------------- 591 3 | 1.41 | yes | torrent-get | added "port" to "peers" 592 | | yes | torrent-get | new arg "downloaders" 593 | | yes | session-get | new arg "version" 594 | | yes | torrent-remove | new method 595 ------+---------+-----------+----------------+------------------------------- 596 4 | 1.50 | yes | session-get | new arg "rpc-version" 597 | | yes | session-get | new arg "rpc-version-minimum" 598 | | yes | session-stats | added "cumulative-stats" 599 | | yes | session-stats | added "current-stats" 600 | | yes | torrent-get | new arg "downloadDir" 601 ------+---------+-----------+----------------+------------------------------- 602 5 | 1.60 | yes | | new method "torrent-reannounce" 603 | | yes | | new method "blocklist-update" 604 | | yes | | new method "port-test" 605 | | | | 606 | | yes | session-get | new arg "alt-speed-begin" 607 | | yes | session-get | new arg "alt-speed-down" 608 | | yes | session-get | new arg "alt-speed-enabled" 609 | | yes | session-get | new arg "alt-speed-end" 610 | | yes | session-get | new arg "alt-speed-time-enabled" 611 | | yes | session-get | new arg "alt-speed-up" 612 | | yes | session-get | new arg "blocklist-enabled" 613 | | yes | session-get | new arg "blocklist-size" 614 | | yes | session-get | new arg "peer-limit-per-torrent" 615 | | yes | session-get | new arg "seedRatioLimit" 616 | | yes | session-get | new arg "seedRatioLimited" 617 | | NO | session-get | renamed "pex-allowed" to "pex-enabled" 618 | | NO | session-get | renamed "port" to "peer-port" 619 | | NO | session-get | renamed "peer-limit" to "peer-limit-global" 620 | | | | 621 | | yes | torrent-add | new arg "files-unwanted" 622 | | yes | torrent-add | new arg "files-wanted" 623 | | yes | torrent-add | new arg "priority-high" 624 | | yes | torrent-add | new arg "priority-low" 625 | | yes | torrent-add | new arg "priority-normal" 626 | | | | 627 | | yes | torrent-set | new arg "bandwidthPriority" 628 | | yes | torrent-set | new arg "honorsSessionLimits" 629 | | yes | torrent-set | new arg "seedRatioLimit" 630 | | yes | torrent-set | new arg "seedRatioLimited" 631 | | NO | torrent-set | renamed "speed-limit-down" to "downloadLimit" 632 | | NO | torrent-set | renamed "speed-limit-down-enabled" to "downloadLimited" 633 | | NO | torrent-set | renamed "speed-limit-up" to "uploadLimit" 634 | | NO | torrent-set | renamed "speed-limit-up-enabled" to "uploadLimited" 635 | | | | 636 | | yes | torrent-get | new arg "bandwidthPriority" 637 | | yes | torrent-get | new arg "fileStats" 638 | | yes | torrent-get | new arg "honorsSessionLimits" 639 | | yes | torrent-get | new arg "percentDone" 640 | | yes | torrent-get | new arg "pieces" 641 | | yes | torrent-get | new arg "seedRatioLimit" 642 | | yes | torrent-get | new arg "seedRatioMode" 643 | | yes | torrent-get | new arg "torrentFile" 644 | | yes | torrent-get | new ids option "recently-active" 645 | | NO | torrent-get | removed arg "downloadLimitMode" 646 | | NO | torrent-get | removed arg "uploadLimitMode" 647 ------+---------+-----------+----------------+------------------------------- 648 6 | 1.70 | yes | | new "method torrent-set-location" 649 ------+---------+-----------+----------------+------------------------------- 650 7 | 1.80 | NO | torrent-get | removed arg "announceResponse" 651 | | NO | torrent-get | removed arg "announceURL" 652 | | NO | torrent-get | removed arg "downloaders" 653 | | NO | torrent-get | removed arg "lastAnnounceTime" 654 | | NO | torrent-get | removed arg "lastScrapeTime" 655 | | NO | torrent-get | removed arg "leechers" 656 | | NO | torrent-get | removed arg "nextAnnounceTime" 657 | | NO | torrent-get | removed arg "nextScrapeTime" 658 | | NO | torrent-get | removed arg "scrapeResponse" 659 | | NO | torrent-get | removed arg "scrapeURL" 660 | | NO | torrent-get | removed arg "seeders" 661 | | NO | torrent-get | removed arg "timesCompleted" 662 | | NO | torrent-get | removed arg "swarmSpeed" 663 | | yes | torrent-get | new arg "magnetLink" 664 | | yes | torrent-get | new arg "metadataPercentComplete" 665 | | yes | torrent-get | new arg "trackerStats" 666 | | yes | session-set | new arg "incomplete-dir" 667 | | yes | session-set | new arg "incomplete-dir-enabled" 668 ------+---------+-----------+----------------+------------------------------- 669 8 | 1.90 | yes | session-set | new arg "rename-partial-files" 670 | | yes | session-get | new arg "rename-partial-files" 671 | | yes | session-get | new arg "config-dir" 672 | | yes | torrent-add | new arg "bandwidthPriority" 673 | | yes | torrent-get | new trackerStats arg "lastAnnounceTimedOut" 674 ------+---------+-----------+----------------+------------------------------- 675 8 | 1.92 | yes | torrent-get | new trackerStats arg "lastScrapeTimedOut" 676 ------+---------+-----------+----------------+------------------------------- 677 9 | 2.00 | yes | session-set | new arg "start-added-torrents" 678 | | yes | session-set | new arg "trash-original-torrent-files" 679 | | yes | session-get | new arg "start-added-torrents" 680 | | yes | session-get | new arg "trash-original-torrent-files" 681 | | yes | torrent-get | new arg "isFinished" 682 ------+---------+-----------+----------------+------------------------------- 683 10 | 2.10 | yes | session-get | new arg "cache-size-mb" 684 | | yes | torrent-set | new arg "trackerAdd" 685 | | yes | torrent-set | new arg "trackerRemove" 686 | | yes | torrent-set | new arg "trackerReplace" 687 | | yes | session-set | new arg "idle-seeding-limit" 688 | | yes | session-set | new arg "idle-seeding-limit-enabled" 689 | | yes | session-get | new arg "units" 690 | | yes | torrent-set | new arg "seedIdleLimit" 691 | | yes | torrent-set | new arg "seedIdleMode" 692 ------+---------+-----------+----------------+------------------------------- 693 11 | 2.12 | yes | session-get | new arg "blocklist-url" 694 | | yes | session-set | new arg "blocklist-url" 695 ------+---------+-----------+----------------+------------------------------- 696 12 | 2.20 | yes | session-get | new arg "download-dir-free-space" 697 | | yes | session-close | new method 698 ------+---------+-----------+----------------+------------------------------- 699 13 | 2.30 | yes | session-get | new arg "isUTP" to the "peers" list 700 | | yes | torrent-add | new arg "cookies" 701 | | NO | torrent-get | removed arg "peersKnown" 702 ------+---------+-----------+----------------+------------------------------- 703 14 | 2.40 | NO | torrent-get | values of "status" field changed 704 | | yes | torrent-get | new arg "queuePosition" 705 | | yes | torrent-get | new arg "isStalled" 706 | | yes | torrent-get | new arg "fromLpd" in peersFrom 707 | | yes | torrent-set | new arg "queuePosition" 708 | | yes | session-set | new arg "download-queue-size" 709 | | yes | session-set | new arg "download-queue-enabled" 710 | | yes | session-set | new arg "seed-queue-size" 711 | | yes | session-set | new arg "seed-queue-enabled" 712 | | yes | session-set | new arg "queue-stalled-enabled" 713 | | yes | session-set | new arg "queue-stalled-minutes" 714 | | yes | | new method "queue-move-top" 715 | | yes | | new method "queue-move-up" 716 | | yes | | new method "queue-move-down" 717 | | yes | | new method "queue-move-bottom" 718 | | yes | | new method "torrent-start-now" 719 ------+---------+-----------+----------------+------------------------------- 720 15 | 2.80 | yes | torrent-get | new arg "etaIdle" 721 603 RPC | Release | Backwards | | 604 Vers. | Version | Compat? | Method | Description 605 ------+---------+-----------+----------------------+------------------------------- 606 1 | 1.30 | n/a | n/a | Initial version 607 ------+---------+-----------+----------------------+------------------------------- 608 2 | 1.34 | yes | torrent-get | new arg "peers" 609 ------+---------+-----------+----------------------+------------------------------- 610 3 | 1.41 | yes | torrent-get | added "port" to "peers" 611 | | yes | torrent-get | new arg "downloaders" 612 | | yes | session-get | new arg "version" 613 | | yes | torrent-remove | new method 614 ------+---------+-----------+----------------------+------------------------------- 615 4 | 1.50 | yes | session-get | new arg "rpc-version" 616 | | yes | session-get | new arg "rpc-version-minimum" 617 | | yes | session-stats | added "cumulative-stats" 618 | | yes | session-stats | added "current-stats" 619 | | yes | torrent-get | new arg "downloadDir" 620 ------+---------+-----------+----------------------+------------------------------- 621 5 | 1.60 | yes | | new method "torrent-reannounce" 622 | | yes | | new method "blocklist-update" 623 | | yes | | new method "port-test" 624 | | | | 625 | | yes | session-get | new arg "alt-speed-begin" 626 | | yes | session-get | new arg "alt-speed-down" 627 | | yes | session-get | new arg "alt-speed-enabled" 628 | | yes | session-get | new arg "alt-speed-end" 629 | | yes | session-get | new arg "alt-speed-time-enabled" 630 | | yes | session-get | new arg "alt-speed-up" 631 | | yes | session-get | new arg "blocklist-enabled" 632 | | yes | session-get | new arg "blocklist-size" 633 | | yes | session-get | new arg "peer-limit-per-torrent" 634 | | yes | session-get | new arg "seedRatioLimit" 635 | | yes | session-get | new arg "seedRatioLimited" 636 | | NO | session-get | renamed "pex-allowed" to "pex-enabled" 637 | | NO | session-get | renamed "port" to "peer-port" 638 | | NO | session-get | renamed "peer-limit" to "peer-limit-global" 639 | | | | 640 | | yes | torrent-add | new arg "files-unwanted" 641 | | yes | torrent-add | new arg "files-wanted" 642 | | yes | torrent-add | new arg "priority-high" 643 | | yes | torrent-add | new arg "priority-low" 644 | | yes | torrent-add | new arg "priority-normal" 645 | | | | 646 | | yes | torrent-set | new arg "bandwidthPriority" 647 | | yes | torrent-set | new arg "honorsSessionLimits" 648 | | yes | torrent-set | new arg "seedRatioLimit" 649 | | yes | torrent-set | new arg "seedRatioLimited" 650 | | NO | torrent-set | renamed "speed-limit-down" to "downloadLimit" 651 | | NO | torrent-set | renamed "speed-limit-down-enabled" to "downloadLimited" 652 | | NO | torrent-set | renamed "speed-limit-up" to "uploadLimit" 653 | | NO | torrent-set | renamed "speed-limit-up-enabled" to "uploadLimited" 654 | | | | 655 | | yes | torrent-get | new arg "bandwidthPriority" 656 | | yes | torrent-get | new arg "fileStats" 657 | | yes | torrent-get | new arg "honorsSessionLimits" 658 | | yes | torrent-get | new arg "percentDone" 659 | | yes | torrent-get | new arg "pieces" 660 | | yes | torrent-get | new arg "seedRatioLimit" 661 | | yes | torrent-get | new arg "seedRatioMode" 662 | | yes | torrent-get | new arg "torrentFile" 663 | | yes | torrent-get | new ids option "recently-active" 664 | | NO | torrent-get | removed arg "downloadLimitMode" 665 | | NO | torrent-get | removed arg "uploadLimitMode" 666 ------+---------+-----------+----------------------+------------------------------- 667 6 | 1.70 | yes | | new "method torrent-set-location" 668 ------+---------+-----------+----------------------+------------------------------- 669 7 | 1.80 | NO | torrent-get | removed arg "announceResponse" 670 | | NO | torrent-get | removed arg "announceURL" 671 | | NO | torrent-get | removed arg "downloaders" 672 | | NO | torrent-get | removed arg "lastAnnounceTime" 673 | | NO | torrent-get | removed arg "lastScrapeTime" 674 | | NO | torrent-get | removed arg "leechers" 675 | | NO | torrent-get | removed arg "nextAnnounceTime" 676 | | NO | torrent-get | removed arg "nextScrapeTime" 677 | | NO | torrent-get | removed arg "scrapeResponse" 678 | | NO | torrent-get | removed arg "scrapeURL" 679 | | NO | torrent-get | removed arg "seeders" 680 | | NO | torrent-get | removed arg "timesCompleted" 681 | | NO | torrent-get | removed arg "swarmSpeed" 682 | | yes | torrent-get | new arg "magnetLink" 683 | | yes | torrent-get | new arg "metadataPercentComplete" 684 | | yes | torrent-get | new arg "trackerStats" 685 | | yes | session-set | new arg "incomplete-dir" 686 | | yes | session-set | new arg "incomplete-dir-enabled" 687 ------+---------+-----------+----------------------+------------------------------- 688 8 | 1.90 | yes | session-set | new arg "rename-partial-files" 689 | | yes | session-get | new arg "rename-partial-files" 690 | | yes | session-get | new arg "config-dir" 691 | | yes | torrent-add | new arg "bandwidthPriority" 692 | | yes | torrent-get | new trackerStats arg "lastAnnounceTimedOut" 693 ------+---------+-----------+----------------------+------------------------------- 694 8 | 1.92 | yes | torrent-get | new trackerStats arg "lastScrapeTimedOut" 695 ------+---------+-----------+----------------------+------------------------------- 696 9 | 2.00 | yes | session-set | new arg "start-added-torrents" 697 | | yes | session-set | new arg "trash-original-torrent-files" 698 | | yes | session-get | new arg "start-added-torrents" 699 | | yes | session-get | new arg "trash-original-torrent-files" 700 | | yes | torrent-get | new arg "isFinished" 701 ------+---------+-----------+----------------------+------------------------------- 702 10 | 2.10 | yes | session-get | new arg "cache-size-mb" 703 | | yes | torrent-set | new arg "trackerAdd" 704 | | yes | torrent-set | new arg "trackerRemove" 705 | | yes | torrent-set | new arg "trackerReplace" 706 | | yes | session-set | new arg "idle-seeding-limit" 707 | | yes | session-set | new arg "idle-seeding-limit-enabled" 708 | | yes | session-get | new arg "units" 709 | | yes | torrent-set | new arg "seedIdleLimit" 710 | | yes | torrent-set | new arg "seedIdleMode" 711 ------+---------+-----------+----------------------+------------------------------- 712 11 | 2.12 | yes | session-get | new arg "blocklist-url" 713 | | yes | session-set | new arg "blocklist-url" 714 ------+---------+-----------+----------------------+------------------------------- 715 12 | 2.20 | yes | session-get | new arg "download-dir-free-space" 716 | | yes | session-close | new method 717 ------+---------+-----------+----------------------+------------------------------- 718 13 | 2.30 | yes | session-get | new arg "isUTP" to the "peers" list 719 | | yes | torrent-add | new arg "cookies" 720 | | NO | torrent-get | removed arg "peersKnown" 721 ------+---------+-----------+--------------------------+------------------------------- 722 14 | 2.40 | NO | torrent-get | values of "status" field changed 723 | | yes | torrent-get | new arg "queuePosition" 724 | | yes | torrent-get | new arg "isStalled" 725 | | yes | torrent-get | new arg "fromLpd" in peersFrom 726 | | yes | torrent-set | new arg "queuePosition" 727 | | yes | session-set | new arg "download-queue-size" 728 | | yes | session-set | new arg "download-queue-enabled" 729 | | yes | session-set | new arg "seed-queue-size" 730 | | yes | session-set | new arg "seed-queue-enabled" 731 | | yes | session-set | new arg "queue-stalled-enabled" 732 | | yes | session-set | new arg "queue-stalled-minutes" 733 | | yes | | new method "queue-move-top" 734 | | yes | | new method "queue-move-up" 735 | | yes | | new method "queue-move-down" 736 | | yes | | new method "queue-move-bottom" 737 | | yes | | new method "torrent-start-now" 738 ------+---------+-----------+--------------------------+------------------------------- 739 15 | 2.80 | yes | torrent-get | new arg "etaIdle" 740 | | yes | torrent-rename-path | new method 741 -
trunk/libtransmission/Makefile.am
r13683 r13807 1 1 AM_CPPFLAGS = \ 2 3 4 2 -I$(top_srcdir) \ 3 -D__TRANSMISSION__ \ 4 -DPACKAGE_DATA_DIR=\""$(datadir)"\" 5 5 6 6 AM_CFLAGS = \ 7 8 9 10 11 12 13 14 15 7 @DHT_CFLAGS@ \ 8 @LIBUTP_CFLAGS@ \ 9 @LIBUPNP_CFLAGS@ \ 10 @LIBNATPMP_CFLAGS@ \ 11 @LIBEVENT_CFLAGS@ \ 12 @LIBCURL_CFLAGS@ \ 13 @OPENSSL_CFLAGS@ \ 14 @PTHREAD_CFLAGS@ \ 15 @ZLIB_CFLAGS@ 16 16 17 17 noinst_LIBRARIES = libtransmission.a 18 18 19 19 libtransmission_a_SOURCES = \ 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 20 announcer.c \ 21 announcer-http.c \ 22 announcer-udp.c \ 23 bandwidth.c \ 24 bitfield.c \ 25 blocklist.c \ 26 cache.c \ 27 clients.c \ 28 completion.c \ 29 ConvertUTF.c \ 30 crypto.c \ 31 fdlimit.c \ 32 handshake.c \ 33 history.c \ 34 inout.c \ 35 list.c \ 36 magnet.c \ 37 makemeta.c \ 38 metainfo.c \ 39 natpmp.c \ 40 net.c \ 41 peer-io.c \ 42 peer-mgr.c \ 43 peer-msgs.c \ 44 platform.c \ 45 port-forwarding.c \ 46 ptrarray.c \ 47 quark.c \ 48 resume.c \ 49 rpcimpl.c \ 50 rpc-server.c \ 51 session.c \ 52 stats.c \ 53 torrent.c \ 54 torrent-ctor.c \ 55 torrent-magnet.c \ 56 tr-dht.c \ 57 tr-lpd.c \ 58 tr-udp.c \ 59 tr-utp.c \ 60 tr-getopt.c \ 61 trevent.c \ 62 upnp.c \ 63 utils.c \ 64 variant.c \ 65 variant-benc.c \ 66 variant-json.c \ 67 verify.c \ 68 web.c \ 69 webseed.c \ 70 wildmat.c 71 71 72 72 noinst_HEADERS = \ 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 73 announcer.h \ 74 announcer-common.h \ 75 bandwidth.h \ 76 bitfield.h \ 77 blocklist.h \ 78 cache.h \ 79 clients.h \ 80 ConvertUTF.h \ 81 crypto.h \ 82 completion.h \ 83 fdlimit.h \ 84 handshake.h \ 85 history.h \ 86 inout.h \ 87 jsonsl.c \ 88 jsonsl.h \ 89 libtransmission-test.h \ 90 list.h \ 91 magnet.h \ 92 makemeta.h \ 93 metainfo.h \ 94 natpmp_local.h \ 95 net.h \ 96 peer-common.h \ 97 peer-io.h \ 98 peer-mgr.h \ 99 peer-msgs.h \ 100 platform.h \ 101 port-forwarding.h \ 102 ptrarray.h \ 103 quark.h \ 104 resume.h \ 105 rpcimpl.h \ 106 rpc-server.h \ 107 session.h \ 108 stats.h \ 109 torrent.h \ 110 torrent-magnet.h \ 111 tr-getopt.h \ 112 transmission.h \ 113 tr-dht.h \ 114 tr-udp.h \ 115 tr-utp.h \ 116 tr-lpd.h \ 117 trevent.h \ 118 upnp.h \ 119 utils.h \ 120 variant.h \ 121 variant-common.h \ 122 verify.h \ 123 version.h \ 124 web.h \ 125 webseed.h 126 126 127 127 TESTS = \ 128 bitfield-test \ 129 blocklist-test \ 130 clients-test \ 131 history-test \ 132 json-test \ 133 magnet-test \ 134 metainfo-test \ 135 peer-msgs-test \ 136 quark-test \ 137 rpc-test \ 138 test-peer-id \ 139 utils-test \ 140 variant-test 128 bitfield-test \ 129 blocklist-test \ 130 clients-test \ 131 history-test \ 132 json-test \ 133 magnet-test \ 134 metainfo-test \ 135 peer-msgs-test \ 136 quark-test \ 137 rename-test \ 138 rpc-test \ 139 test-peer-id \ 140 utils-test \ 141 variant-test 141 142 142 143 noinst_PROGRAMS = $(TESTS) 143 144 144 145 apps_ldflags = \ 145 146 @ZLIB_LDFLAGS@ 146 147 147 148 apps_ldadd = \ 148 149 150 151 152 153 154 155 156 157 158 149 ./libtransmission.a \ 150 @LIBUPNP_LIBS@ \ 151 @LIBNATPMP_LIBS@ \ 152 @INTLLIBS@ \ 153 @DHT_LIBS@ \ 154 @LIBUTP_LIBS@ \ 155 @LIBCURL_LIBS@ \ 156 @LIBEVENT_LIBS@ \ 157 @OPENSSL_LIBS@ \ 158 @PTHREAD_LIBS@ \ 159 @ZLIB_LIBS@ 159 160 160 161 TEST_SOURCES = libtransmission-test.c … … 211 212 variant_test_LDADD = ${apps_ldadd} 212 213 variant_test_LDFLAGS = ${apps_ldflags} 214 215 rename_test_SOURCES = rename-test.c $(TEST_SOURCES) 216 rename_test_LDADD = ${apps_ldadd} 217 rename_test_LDFLAGS = ${apps_ldflags} -
trunk/libtransmission/resume.c
r13683 r13807 336 336 return ret; 337 337 } 338 339 /*** 340 **** 341 ***/ 342 343 static void 344 saveFilenames (tr_variant * dict, const tr_torrent * tor) 345 { 346 tr_file_index_t i; 347 bool any_renamed; 348 const tr_file_index_t n = tor->info.fileCount; 349 const tr_file * files = tor->info.files; 350 351 any_renamed = false; 352 for (i=0; !any_renamed && i<n; ++i) 353 any_renamed = files[i].is_renamed; 354 355 if (any_renamed) 356 { 357 tr_variant * list = tr_variantDictAddList (dict, TR_KEY_files, n); 358 359 for (i=0; i<n; ++i) 360 tr_variantListAddStr (list, files[i].is_renamed ? files[i].name : ""); 361 } 362 } 363 364 static uint64_t 365 loadFilenames (tr_variant * dict, tr_torrent * tor) 366 { 367 tr_variant * list; 368 uint64_t ret = 0; 369 370 if (tr_variantDictFindList (dict, TR_KEY_files, &list)) 371 { 372 size_t i; 373 const size_t n = tr_variantListSize (list); 374 tr_file * files = tor->info.files; 375 376 for (i=0; i<tor->info.fileCount && i<n; ++i) 377 { 378 const char * str; 379 size_t str_len; 380 if (tr_variantGetStr (tr_variantListChild (list, i), &str, &str_len) && str && str_len) 381 { 382 tr_free (files[i].name); 383 files[i].name = tr_strndup (str, str_len); 384 files[i].is_renamed = true; 385 } 386 } 387 388 ret = TR_FR_FILENAMES; 389 } 390 391 return ret; 392 } 393 338 394 /*** 339 395 **** … … 594 650 saveRatioLimits (&top, tor); 595 651 saveIdleLimits (&top, tor); 652 saveFilenames (&top, tor); 596 653 597 654 filename = getResumeFilename (tor); … … 746 803 fieldsLoaded |= loadIdleLimits (&top, tor); 747 804 805 if (fieldsToLoad & TR_FR_FILENAMES) 806 fieldsLoaded |= loadFilenames (&top, tor); 807 748 808 /* loading the resume file triggers of a lot of changes, 749 809 * but none of them needs to trigger a re-saving of the -
trunk/libtransmission/resume.h
r13625 r13807 39 39 TR_FR_IDLELIMIT = (1 << 17), 40 40 TR_FR_TIME_SEEDING = (1 << 18), 41 TR_FR_TIME_DOWNLOADING = (1 << 19) 41 TR_FR_TIME_DOWNLOADING = (1 << 19), 42 TR_FR_FILENAMES = (1 << 20) 42 43 }; 43 44 -
trunk/libtransmission/rpcimpl.c
r13787 r13807 85 85 { 86 86 tr_session * session; 87 tr_variant 88 tr_variant 87 tr_variant * response; 88 tr_variant * args_out; 89 89 tr_rpc_response_func callback; 90 90 void * callback_user_data; … … 115 115 static tr_torrent ** 116 116 getTorrents (tr_session * session, 117 tr_variant 117 tr_variant * args, 118 118 int * setmeCount) 119 119 { … … 197 197 static const char* 198 198 queueMoveTop (tr_session * session, 199 tr_variant 200 tr_variant 199 tr_variant * args_in, 200 tr_variant * args_out UNUSED, 201 201 struct tr_rpc_idle_data * idle_data UNUSED) 202 202 { … … 211 211 static const char* 212 212 queueMoveUp (tr_session * session, 213 tr_variant 214 tr_variant 213 tr_variant * args_in, 214 tr_variant * args_out UNUSED, 215 215 struct tr_rpc_idle_data * idle_data UNUSED) 216 216 { … … 225 225 static const char* 226 226 queueMoveDown (tr_session * session, 227 tr_variant 228 tr_variant 227 tr_variant * args_in, 228 tr_variant * args_out UNUSED, 229 229 struct tr_rpc_idle_data * idle_data UNUSED) 230 230 { … … 239 239 static const char* 240 240 queueMoveBottom (tr_session * session, 241 tr_variant 242 tr_variant 241 tr_variant * args_in, 242 tr_variant * args_out UNUSED, 243 243 struct tr_rpc_idle_data * idle_data UNUSED) 244 244 { … … 253 253 static const char* 254 254 torrentStart (tr_session * session, 255 tr_variant 256 tr_variant 255 tr_variant * args_in, 256 tr_variant * args_out UNUSED, 257 257 struct tr_rpc_idle_data * idle_data UNUSED) 258 258 { … … 277 277 static const char* 278 278 torrentStartNow (tr_session * session, 279 tr_variant 280 tr_variant 279 tr_variant * args_in, 280 tr_variant * args_out UNUSED, 281 281 struct tr_rpc_idle_data * idle_data UNUSED) 282 282 { … … 301 301 static const char* 302 302 torrentStop (tr_session * session, 303 tr_variant 304 tr_variant 303 tr_variant * args_in, 304 tr_variant * args_out UNUSED, 305 305 struct tr_rpc_idle_data * idle_data UNUSED) 306 306 { … … 326 326 static const char* 327 327 torrentRemove (tr_session * session, 328 tr_variant 329 tr_variant 328 tr_variant * args_in, 329 tr_variant * args_out UNUSED, 330 330 struct tr_rpc_idle_data * idle_data UNUSED) 331 331 { … … 354 354 } 355 355 356 static void 357 torrentRenamePathDone (tr_torrent * tor UNUSED, 358 const char * oldpath UNUSED, 359 const char * newname UNUSED, 360 int error, 361 void * user_data) 362 { 363 *(int*)user_data = error; 364 } 365 366 static const char * 367 torrentRenamePath (tr_session * session, 368 tr_variant * args_in, 369 tr_variant * args_out UNUSED, 370 struct tr_rpc_idle_data * idle_data UNUSED) 371 { 372 const char * oldpath; 373 const char * newname; 374 const char * ret = NULL; 375 376 if (!tr_variantDictFindStr (args_in, TR_KEY_path, &oldpath, NULL)) 377 { 378 ret = "no path specified"; 379 } 380 else if (!tr_variantDictFindStr (args_in, TR_KEY_name, &newname, NULL)) 381 { 382 ret = "no name specified"; 383 } 384 else 385 { 386 int torrentCount; 387 tr_torrent ** torrents = getTorrents (session, args_in, &torrentCount); 388 389 if (torrentCount != 1) 390 { 391 ret = "torent-rename-path requires 1 torrent"; 392 } 393 else 394 { 395 int error = -1; 396 tr_torrentRenamePath (torrents[0], oldpath, newname, torrentRenamePathDone, &error); 397 assert (error != -1); 398 399 if (error != 0) 400 ret = tr_strerror (error); 401 } 402 403 tr_free (torrents); 404 } 405 406 return ret; 407 } 408 356 409 static const char* 357 410 torrentReannounce (tr_session * session, 358 tr_variant 359 tr_variant 411 tr_variant * args_in, 412 tr_variant * args_out UNUSED, 360 413 struct tr_rpc_idle_data * idle_data UNUSED) 361 414 { … … 381 434 static const char* 382 435 torrentVerify (tr_session * session, 383 tr_variant 384 tr_variant 436 tr_variant * args_in, 437 tr_variant * args_out UNUSED, 385 438 struct tr_rpc_idle_data * idle_data UNUSED) 386 439 { … … 1934 1987 { "torrent-get", true, torrentGet }, 1935 1988 { "torrent-remove", true, torrentRemove }, 1989 { "torrent-rename-path", true, torrentRenamePath }, 1936 1990 { "torrent-set", true, torrentSet }, 1937 1991 { "torrent-set-location", true, torrentSetLocation }, -
trunk/libtransmission/torrent.c
r13783 r13807 3303 3303 3304 3304 3305 /*** 3306 **** 3307 **** RENAME 3308 **** 3309 ***/ 3310 3311 static bool 3312 renameArgsAreValid (const char * oldpath, const char * newname) 3313 { 3314 return (oldpath && *oldpath) 3315 && (newname && *newname) 3316 && (strcmp (newname, ".")) 3317 && (strcmp (newname, "..")) 3318 && (strchr (newname, TR_PATH_DELIMITER) == NULL); 3319 } 3320 3321 static tr_file_index_t * 3322 renameFindAffectedFiles (tr_torrent * tor, const char * oldpath, size_t * setme_n) 3323 { 3324 size_t n; 3325 size_t oldpath_len; 3326 tr_file_index_t i; 3327 tr_file_index_t * indices = tr_new0 (tr_file_index_t, tor->info.fileCount); 3328 3329 n = 0; 3330 oldpath_len = strlen (oldpath); 3331 for (i=0; i!=tor->info.fileCount; ++i) 3332 { 3333 const char * name = tor->info.files[i].name; 3334 const size_t len = strlen (name); 3335 if ((len >= oldpath_len) && !memcmp (oldpath, name, oldpath_len)) 3336 indices[n++] = i; 3337 } 3338 3339 *setme_n = n; 3340 return indices; 3341 } 3342 3343 static int 3344 renamePath (tr_torrent * tor, 3345 const char * oldpath, 3346 const char * newname) 3347 { 3348 char * src; 3349 const char * base; 3350 int error = 0; 3351 3352 if (!tr_torrentIsSeed(tor) && (tor->incompleteDir != NULL)) 3353 base = tor->incompleteDir; 3354 else 3355 base = tor->downloadDir; 3356 3357 src = tr_buildPath (base, oldpath, NULL); 3358 /*fprintf (stderr, "%s:%d src \"%s\"\n", __FILE__, __LINE__, src);*/ 3359 3360 if (tr_fileExists (src, NULL)) 3361 { 3362 int tmp; 3363 bool tgt_exists; 3364 char * parent = tr_dirname (src); 3365 char * tgt = tr_buildPath (parent, newname, NULL); 3366 3367 tmp = errno; 3368 tgt_exists = tr_fileExists (tgt, NULL); 3369 errno = tmp; 3370 /*fprintf (stderr, "%s:%d tgt \"%s\"\n", __FILE__, __LINE__, tgt);*/ 3371 3372 if (!tgt_exists) 3373 { 3374 int rv; 3375 3376 tmp = errno; 3377 rv = rename (src, tgt); 3378 /*fprintf (stderr, "%s:%d rv \"%d\"\n", __FILE__, __LINE__, rv);*/ 3379 if (rv != 0) 3380 error = errno; 3381 errno = tmp; 3382 } 3383 3384 tr_free (tgt); 3385 tr_free (parent); 3386 } 3387 3388 tr_free (src); 3389 3390 return error; 3391 } 3392 3393 static void 3394 renameTorrentFileString (tr_torrent * tor, 3395 const char * oldpath, 3396 const char * newname, 3397 tr_file_index_t fileIndex) 3398 { 3399 char * name; 3400 tr_file * file = &tor->info.files[fileIndex]; 3401 const size_t oldpath_len = strlen (oldpath); 3402 3403 if (strchr (oldpath, TR_PATH_DELIMITER) == NULL) 3404 { 3405 if (oldpath_len >= strlen(file->name)) 3406 name = tr_buildPath (newname, NULL); 3407 else 3408 name = tr_buildPath (newname, file->name + oldpath_len + 1, NULL); 3409 } 3410 else 3411 { 3412 char * tmp = tr_dirname (oldpath); 3413 3414 if (oldpath_len >= strlen(file->name)) 3415 name = tr_buildPath (tmp, newname, NULL); 3416 else 3417 name = tr_buildPath (tmp, newname, file->name + oldpath_len + 1, NULL); 3418 3419 tr_free (tmp); 3420 } 3421 3422 if (!strcmp (file->name, name)) 3423 { 3424 tr_free (name); 3425 } 3426 else 3427 { 3428 tr_free (file->name); 3429 file->name = name; 3430 file->is_renamed = true; 3431 } 3432 } 3433 3434 struct rename_data 3435 { 3436 tr_torrent * tor; 3437 char * oldpath; 3438 char * newname; 3439 tr_torrent_rename_done_func * callback; 3440 void * callback_user_data; 3441 }; 3442 3443 static void 3444 torrentRenamePath (void * vdata) 3445 { 3446 int error = 0; 3447 struct rename_data * data = vdata; 3448 tr_torrent * const tor = data->tor; 3449 const char * const oldpath = data->oldpath; 3450 const char * const newname = data->newname; 3451 3452 /*** 3453 **** 3454 ***/ 3455 3456 assert (tr_isTorrent (tor)); 3457 3458 if (!renameArgsAreValid (oldpath, newname)) 3459 { 3460 error = EINVAL; 3461 } 3462 else 3463 { 3464 size_t n; 3465 tr_file_index_t * file_indices; 3466 3467 file_indices = renameFindAffectedFiles (tor, oldpath, &n); 3468 if (n == 0) 3469 { 3470 errno = EINVAL; 3471 } 3472 else 3473 { 3474 size_t i; 3475 3476 error = renamePath (tor, oldpath, newname); 3477 3478 if (!error) 3479 { 3480 for (i=0; i<n; ++i) 3481 renameTorrentFileString(tor, oldpath, newname, file_indices[i]); 3482 tr_torrentSetDirty (tor); 3483 } 3484 } 3485 3486 tr_free (file_indices); 3487 } 3488 3489 3490 /*** 3491 **** 3492 ***/ 3493 3494 /* callback */ 3495 if (data->callback != NULL) 3496 (*data->callback)(tor, data->oldpath, data->newname, error, data->callback_user_data); 3497 3498 /* cleanup */ 3499 tr_free (data->oldpath); 3500 tr_free (data->newname); 3501 tr_free (data); 3502 } 3503 3504 void 3505 tr_torrentRenamePath (tr_torrent * tor, 3506 const char * oldpath, 3507 const char * newname, 3508 tr_torrent_rename_done_func callback, 3509 void * callback_user_data) 3510 { 3511 struct rename_data * data; 3512 3513 data = tr_new0 (struct rename_data, 1); 3514 data->tor = tor; 3515 data->oldpath = tr_strdup (oldpath); 3516 data->newname = tr_strdup (newname); 3517 data->callback = callback; 3518 data->callback_user_data = callback_user_data; 3519 3520 tr_runInEventThread (tor->session, torrentRenamePath, data); 3521 } -
trunk/libtransmission/transmission.h
r13802 r13807 1094 1094 void tr_torrentStop (tr_torrent * torrent); 1095 1095 1096 1097 typedef void (tr_torrent_rename_done_func)(tr_torrent * torrent, 1098 const char * oldpath, 1099 const char * newname, 1100 int error, 1101 void * user_data); 1102 1103 /** 1104 * @brief Rename a file or directory in a torrent. 1105 * 1106 * @tor: the torrent whose path will be renamed. 1107 * @oldpath: the path to the file or folder that will be renamed 1108 * @newname: the file or folder's new name 1109 * @callback: the callback invoked when the renaming finishes, or NULL 1110 * @callback_data: the pointer to pass in the callback's user_data arg 1111 * 1112 * EXAMPLES 1113 * 1114 * Consider a torrent where 1115 * files[0].path is "frobnitz-linux/checksum" and 1116 * files[1].path is "frobnitz-linux/frobnitz.iso". 1117 * 1118 * 1. tr_torrentRenamePath (tor, "frobnitz-linux", "foo") will rename 1119 * the "frotbnitz-linux" folder as "foo" and update files[*].path. 1120 * 1121 * 2. tr_torrentRenamePath (tor, "frobnitz-linux/checksum", "foo") will 1122 * rename the "frobnitz-linux/checksum" file as "foo" and update 1123 * files[0].path to "frobnitz-linux/foo". 1124 * 1125 * RETURN 1126 * 1127 * Changing tr_info's contents requires a session lock, so this function 1128 * returns asynchronously to avoid blocking. If you don't care about error 1129 * checking, you can pass NULL as the callback and callback_user_data arg. 1130 * 1131 * On success, the callback's error argument will be 0. 1132 * 1133 * If oldpath can't be found in files[*].path, or if newname is already 1134 * in files[*].path, or contains a directory separator, or is NULL, "", 1135 * ".", or "..", the error argument will be EINVAL. 1136 * 1137 * If the path exists on disk but can't be renamed, the error argument 1138 * will be the errno set by rename(). 1139 */ 1140 void tr_torrentRenamePath (tr_torrent * tor, 1141 const char * oldpath, 1142 const char * newname, 1143 tr_torrent_rename_done_func callback, 1144 void * callback_user_data); 1145 1146 1096 1147 enum 1097 1148 { … … 1354 1405 */ 1355 1406 typedef void (tr_torrent_completeness_func)(tr_torrent * torrent, 1356 1357 1358 1407 tr_completeness completeness, 1408 bool wasRunning, 1409 void * user_data); 1359 1410 1360 1411 typedef void (tr_torrent_ratio_limit_hit_func)(tr_torrent * torrent, 1361 1412 void * user_data); 1362 1413 1363 1414 typedef void (tr_torrent_idle_limit_hit_func)(tr_torrent * torrent, 1364 1415 void * user_data); 1365 1416 1366 1417 … … 1684 1735 int8_t priority; /* TR_PRI_HIGH, _NORMAL, or _LOW */ 1685 1736 int8_t dnd; /* "do not download" flag */ 1737 int8_t is_renamed; /* true if we're using a different path from the one in the metainfo; ie, if the user has renamed it */ 1686 1738 tr_piece_index_t firstPiece; /* We need pieces [firstPiece... */ 1687 1739 tr_piece_index_t lastPiece; /* ...lastPiece] to dl this file */
Note: See TracChangeset
for help on using the changeset viewer.