When using --partial-dir, an interrupted transfer of a read-only file
fails on retry.  When using --partial instead, the retry succeeds.
This is regardless whether the target file is local or remote (ssh).

The attached script reproduces the problem.

    OS: Debian 13/Trixie
    % rsync --version
    rsync  version 3.4.1  protocol version 32
    Copyright (C) 1996-2025 by Andrew Tridgell, Wayne Davison, and others.
    Web site: https://rsync.samba.org/
    Capabilities:
        64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
        socketpairs, symlinks, symtimes, hardlinks, hardlink-specials,
        hardlink-symlinks, IPv6, atimes, batchfiles, inplace, append, ACLs,
        xattrs, optional secluded-args, iconv, prealloc, stop-at, no crtimes
    Optimizations:
        SIMD-roll, no asm-roll, openssl-crypto, no asm-MD5
    Checksum list:
        xxh128 xxh3 xxh64 (xxhash) md5 md4 sha1 none
    Compress list:
        zstd lz4 zlibx zlib none
    Daemon auth list:
        sha512 sha256 sha1 md5 md4

TNX
R'

Script:
---snip------------------------------------------
#!/bin/sh
#
# Summary: using --partial-dir=.rsync to transfer a read-only file
# fails on retry when the initial transfer is interrupted.
#
# Using  --partial instead succeeds to transfer the file if the
# transfer is interrupted.

###########################
# files: source
datafile=datafile
# rsync target
outputfile=datafile.out
# staging dir for --partial-dir
stagingdir=.rsync

# show the bug with --partial-dir
partialopt="--partial-dir=$stagingdir"

# using --partial instead does not have the problem,
# although the partial file is readonly, too
# uncomment next line to show
# partialopt=--partial
###########################

# create large file
test -f $datafile || dd if=/dev/random bs=1G count=1 > $datafile

# make the file readonly
chmod 444 $datafile

# remove staging dir and rsync target file
rm -rf $stagingdir $outputfile

# transfer the file via rsync and interrupt the transfer
rsync -av --progress $partialopt $datafile $outputfile &
pid=$!
sleep 0.1
kill $pid

# collect rsync zombie
wait

# check the file(s)
ls -l
# note: file is partially transferred in the staging dir and *read-only*
test -d $stagingdir && ls -la $stagingdir

# if we change the target file in the staging dir to rw here, no problem
# chmod 600 $stagingdir/$outputfile

# restart rsync
echo restarting rsync
rsync -av --progress $partialopt $datafile $outputfile

# show result
ls -l
test -d $stagingdir && ls -la $stagingdir

# EOF
---snip------------------------------------------

-- 
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html

Reply via email to