mirror of
https://github.com/transmission/transmission
synced 2024-12-25 01:03:01 +00:00
(trunk libt) #4305 "New Torrent via RPC Error:No data found when subfolder does not exist" -- revert r12076 s.t. parent directories are created as necessary when saving local data to disk.
This commit is contained in:
parent
feb4ddadd5
commit
434a988165
3 changed files with 3 additions and 19 deletions
|
@ -342,7 +342,6 @@ cached_file_close( struct tr_cached_file * o )
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
cached_file_open( struct tr_cached_file * o,
|
cached_file_open( struct tr_cached_file * o,
|
||||||
const char * existing_dir,
|
|
||||||
const char * filename,
|
const char * filename,
|
||||||
bool writable,
|
bool writable,
|
||||||
tr_preallocation_mode allocation,
|
tr_preallocation_mode allocation,
|
||||||
|
@ -352,14 +351,6 @@ cached_file_open( struct tr_cached_file * o,
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
bool alreadyExisted;
|
bool alreadyExisted;
|
||||||
|
|
||||||
/* confirm that existing_dir, if specified, exists on the disk */
|
|
||||||
if( existing_dir && *existing_dir && stat( existing_dir, &sb ) )
|
|
||||||
{
|
|
||||||
const int err = errno;
|
|
||||||
tr_err( _( "Couldn't open \"%1$s\": %2$s" ), existing_dir, tr_strerror( err ) );
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* create subfolders, if any */
|
/* create subfolders, if any */
|
||||||
if( writable )
|
if( writable )
|
||||||
{
|
{
|
||||||
|
@ -631,7 +622,6 @@ int
|
||||||
tr_fdFileCheckout( tr_session * session,
|
tr_fdFileCheckout( tr_session * session,
|
||||||
int torrent_id,
|
int torrent_id,
|
||||||
tr_file_index_t i,
|
tr_file_index_t i,
|
||||||
const char * existing_dir,
|
|
||||||
const char * filename,
|
const char * filename,
|
||||||
bool writable,
|
bool writable,
|
||||||
tr_preallocation_mode allocation,
|
tr_preallocation_mode allocation,
|
||||||
|
@ -647,7 +637,7 @@ tr_fdFileCheckout( tr_session * session,
|
||||||
|
|
||||||
if( !cached_file_is_open( o ) )
|
if( !cached_file_is_open( o ) )
|
||||||
{
|
{
|
||||||
const int err = cached_file_open( o, existing_dir, filename, writable, allocation, file_size );
|
const int err = cached_file_open( o, filename, writable, allocation, file_size );
|
||||||
if( err ) {
|
if( err ) {
|
||||||
errno = err;
|
errno = err;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -51,11 +51,6 @@ int tr_prefetch(int fd, off_t offset, size_t count);
|
||||||
* - if do_write is true, subfolders in torrentFile are created if necessary.
|
* - if do_write is true, subfolders in torrentFile are created if necessary.
|
||||||
* - if do_write is true, the target file is created if necessary.
|
* - if do_write is true, the target file is created if necessary.
|
||||||
*
|
*
|
||||||
* @param existing_dir An ancestor of filename which must already exist and
|
|
||||||
* won't be created by tr_fdFileCheckout(). This prevents
|
|
||||||
* directories from being created in error, such as a mount
|
|
||||||
* point for an external drive when the drive is unplugged.
|
|
||||||
*
|
|
||||||
* on success, a file descriptor >= 0 is returned.
|
* on success, a file descriptor >= 0 is returned.
|
||||||
* on failure, a -1 is returned and errno is set.
|
* on failure, a -1 is returned and errno is set.
|
||||||
*
|
*
|
||||||
|
@ -64,9 +59,8 @@ int tr_prefetch(int fd, off_t offset, size_t count);
|
||||||
int tr_fdFileCheckout( tr_session * session,
|
int tr_fdFileCheckout( tr_session * session,
|
||||||
int torrent_id,
|
int torrent_id,
|
||||||
tr_file_index_t file_num,
|
tr_file_index_t file_num,
|
||||||
const char * existing_dir,
|
|
||||||
const char * filename,
|
const char * filename,
|
||||||
bool do_write,
|
bool do_write,
|
||||||
tr_preallocation_mode preallocation_mode,
|
tr_preallocation_mode preallocation_mode,
|
||||||
uint64_t preallocation_file_size );
|
uint64_t preallocation_file_size );
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ readOrWriteBytes( tr_session * session,
|
||||||
? TR_PREALLOCATE_NONE
|
? TR_PREALLOCATE_NONE
|
||||||
: tor->session->preallocationMode;
|
: tor->session->preallocationMode;
|
||||||
if((( fd = tr_fdFileCheckout( session, tor->uniqueId, fileIndex,
|
if((( fd = tr_fdFileCheckout( session, tor->uniqueId, fileIndex,
|
||||||
base, filename, doWrite,
|
filename, doWrite,
|
||||||
prealloc, file->length ))) < 0 )
|
prealloc, file->length ))) < 0 )
|
||||||
{
|
{
|
||||||
err = errno;
|
err = errno;
|
||||||
|
|
Loading…
Reference in a new issue