Changeset 14147
- Timestamp:
- Jul 27, 2013, 4:18:12 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/fdlimit.c
r13905 r14147 336 336 int flags; 337 337 struct stat sb; 338 bool alreadyExisted; 338 bool already_existed; 339 bool resize_needed; 339 340 340 341 /* create subfolders, if any */ … … 352 353 } 353 354 354 already Existed = !stat (filename, &sb) && S_ISREG (sb.st_mode);355 356 if (writable && !already Existed && (allocation == TR_PREALLOCATE_FULL))355 already_existed = !stat (filename, &sb) && S_ISREG (sb.st_mode); 356 357 if (writable && !already_existed && (allocation == TR_PREALLOCATE_FULL)) 357 358 if (preallocate_file_full (filename, file_size)) 358 359 tr_logAddDebug ("Preallocated file \"%s\"", filename); 360 361 /* we can't resize the file w/o write permissions */ 362 resize_needed = already_existed && (file_size < (uint64_t)sb.st_size); 363 writable |= resize_needed; 359 364 360 365 /* open the file */ … … 376 381 * https://bugs.launchpad.net/ubuntu/+source/transmission/+bug/318249 377 382 */ 378 if (alreadyExisted && (file_size < (uint64_t)sb.st_size)) 379 { 380 if (ftruncate (o->fd, file_size) == -1) 381 { 382 const int err = errno; 383 tr_logAddError (_("Couldn't truncate \"%1$s\": %2$s"), filename, tr_strerror (err)); 384 return err; 385 } 386 } 387 388 if (writable && !alreadyExisted && (allocation == TR_PREALLOCATE_SPARSE)) 383 if (resize_needed && (ftruncate (o->fd, file_size) == -1)) 384 { 385 const int err = errno; 386 tr_logAddError (_("Couldn't truncate \"%1$s\": %2$s"), filename, tr_strerror (err)); 387 return err; 388 } 389 390 if (writable && !already_existed && (allocation == TR_PREALLOCATE_SPARSE)) 389 391 preallocate_file_sparse (o->fd, file_size); 390 392
Note: See TracChangeset
for help on using the changeset viewer.