Changeset 11627


Ignore:
Timestamp:
Jan 5, 2011, 4:41:19 AM (11 years ago)
Author:
jordan
Message:

(trunk, daemon) #3833 "'freespace' argument for 'session-get' RPC method" -- committing patch from taem, reardon, and rb07

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r11548 r11627  
    109109AC_HEADER_TIME
    110110
    111 AC_CHECK_FUNCS([iconv_open pread pwrite lrintf strlcpy daemon dirname basename strcasecmp localtime_r fallocate64 posix_fallocate memmem strsep strtold syslog valloc getpagesize posix_memalign])
     111AC_CHECK_FUNCS([iconv_open pread pwrite lrintf strlcpy daemon dirname basename strcasecmp localtime_r fallocate64 posix_fallocate memmem strsep strtold syslog valloc getpagesize posix_memalign statvfs])
    112112AC_PROG_INSTALL
    113113AC_PROG_MAKE_SET
     
    175175fi
    176176
    177 AC_CHECK_HEADERS([xfs/xfs.h])
     177AC_CHECK_HEADERS([sys/statvfs.h \
     178                  xfs/xfs.h])
    178179
    179180
  • trunk/daemon/remote.c

    r11599 r11627  
    14611461        if( tr_bencDictFindStr( args,  TR_PREFS_KEY_DOWNLOAD_DIR, &str ) )
    14621462            printf( "  Download directory: %s\n", str );
     1463        if( tr_bencDictFindInt( args,  "download-dir-free-space", &i ) )
     1464            printf( "  Download directory free space: %s\n",  strlsize( buf, i, sizeof buf ) );
    14631465        if( tr_bencDictFindInt( args, TR_PREFS_KEY_PEER_PORT, &i ) )
    14641466            printf( "  Listenport: %" PRId64 "\n", i );
  • trunk/extras/rpc-spec.txt

    r11597 r11627  
    418418   "config-dir"                     | string     | location of transmission's configuration directory
    419419   "download-dir"                   | string     | default path to download torrents
     420   "download-dir-free-space"        | number     | number of free bytes available in download-dir, or -1 if it can't be calculated
    420421   "dht-enabled"                    | boolean    | true means allow dht in public torrents
    421422   "encryption"                     | string     | "required", "preferred", "tolerated"
     
    469470   Method name: "session-set"
    470471   Request arguments: one or more of 4.1's arguments, except: "blocklist-size",
    471                       "config-dir", "rpc-version", "rpc-version-minimum",
    472                       and "version"
     472                      "config-dir", "download-dir-free-space", "rpc-version",
     473                      "rpc-version-minimum", and "version"
    473474   Response arguments: none
    474475
     
    643644   11    | 2.12    | yes       | session-get    | new arg "blocklist-url"
    644645         |         | yes       | session-set    | new arg "blocklist-url"
     646   ------+---------+-----------+----------------+-------------------------------
     647   12    | 2.20    | yes       | session-get    | new arg "download-dir-free-space"
  • trunk/libtransmission/platform.c

    r11599 r11627  
    3535#include <string.h>
    3636
     37#ifdef SYS_DARWIN
     38 #define HAVE_SYS_STATVFS_H
     39 #define HAVE_STATVFS
     40#endif
     41
    3742#include <sys/stat.h>
    3843#include <sys/types.h>
     44#ifdef HAVE_SYS_STATVFS_H
     45 #include <sys/statvfs.h>
     46#endif
    3947#ifdef WIN32
    4048#include <libgen.h>
     
    679687***/
    680688
     689int64_t
     690tr_getFreeSpace( const char * path )
     691{
     692#ifdef WIN32
     693    uint64_t freeBytesAvailable = 0;
     694    return GetDiskFreeSpaceEx( path, &freeBytesAvailable, NULL, NULL)
     695        ? (int64_t)freeBytesAvailable
     696        : -1;
     697#elif defined(HAVE_STATVFS)
     698    struct statvfs buf;
     699    return statvfs( path, &buf ) ? -1 : (int64_t)buf.f_bavail * (int64_t)buf.f_bsize;
     700#else
     701    #warning FIXME: not implemented
     702    return -1;
     703#endif
     704}
     705
     706/***
     707****
     708***/
     709
    681710#ifdef WIN32
    682711
     
    798827
    799828#endif
    800 
  • trunk/libtransmission/platform.h

    r11599 r11627  
    5555const char * tr_getWebClientDir( const tr_session * );
    5656
     57/** @brief return the number of bytes available for use in the specified path, or -1 on error */
     58int64_t tr_getFreeSpace( const char * path );
     59
     60
    5761/** @} */
    5862
  • trunk/libtransmission/rpcimpl.c

    r11599 r11627  
    15831583    tr_bencDictAddStr ( d, "config-dir", tr_sessionGetConfigDir( s ) );
    15841584    tr_bencDictAddStr ( d, TR_PREFS_KEY_DOWNLOAD_DIR, tr_sessionGetDownloadDir( s ) );
     1585    tr_bencDictAddInt ( d, "download-dir-free-space",  tr_sessionGetDownloadDirFreeSpace( s ) );
    15851586    tr_bencDictAddInt ( d, TR_PREFS_KEY_PEER_LIMIT_GLOBAL, tr_sessionGetPeerLimit( s ) );
    15861587    tr_bencDictAddInt ( d, TR_PREFS_KEY_PEER_LIMIT_TORRENT, tr_sessionGetPeerLimitPerTorrent( s ) );
     
    16161617    }
    16171618    tr_bencDictAddStr( d, TR_PREFS_KEY_ENCRYPTION, str );
    1618 
     1619   
    16191620    return NULL;
    16201621}
  • trunk/libtransmission/session.c

    r11624 r11627  
    883883}
    884884
     885int64_t
     886tr_sessionGetDownloadDirFreeSpace( const tr_session * session )
     887{
     888    assert( tr_isSession( session ) );
     889
     890    return tr_getFreeSpace( session->downloadDir );
     891}
     892
    885893/***
    886894****
  • trunk/libtransmission/transmission.h

    r11614 r11627  
    339339const char * tr_sessionGetDownloadDir( const tr_session * session );
    340340
     341/**
     342 * @brief Get available disk space (in bytes) for the default download folder.
     343 * @return zero or positive integer on success, -1 in case of error.
     344 */
     345int64_t tr_sessionGetDownloadDirFreeSpace( const tr_session * session );
    341346
    342347/**
Note: See TracChangeset for help on using the changeset viewer.