mirror of
https://github.com/samba-team/samba.git
synced 2025-01-31 01:48:16 +03:00
s3:utils/smbget fix recursive download with empty source directories
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13199 Signed-off-by: Christian Ambach <ambi@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Fri Oct 26 09:58:07 CEST 2018 on sn-devel-144 (cherry picked from commit fce0d1b290c7a2205f2454b268b55909d1044f1b) Autobuild-User(v4-8-test): Karolin Seeger <kseeger@samba.org> Autobuild-Date(v4-8-test): Mon Jan 7 15:56:31 CET 2019 on sn-devel-144
This commit is contained in:
parent
7aba48de14
commit
5067926e4f
@ -43,7 +43,7 @@ remove_test_data()
|
||||
}
|
||||
|
||||
clear_download_area() {
|
||||
rm -rf dir1 dir2 testfile
|
||||
rm -rf dir1 dir2 testfile dir001 dir004
|
||||
}
|
||||
|
||||
test_singlefile_guest()
|
||||
@ -155,6 +155,39 @@ test_recursive_existing_dir()
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
test_recursive_with_empty() # see Bug 13199
|
||||
{
|
||||
clear_download_area
|
||||
# create some additional empty directories
|
||||
mkdir -p $WORKDIR/dir001/dir002/dir003
|
||||
mkdir -p $WORKDIR/dir004/dir005/dir006
|
||||
$SMBGET -v -R -U$USERNAME%$PASSWORD smb://$SERVER_IP/smbget/
|
||||
rc=$?
|
||||
rm -rf $WORKDIR/dir001
|
||||
rm -rf $WORKDIR/dir004
|
||||
if [ $rc -ne 0 ]; then
|
||||
echo 'ERROR: RC does not match, expected: 0'
|
||||
return 1
|
||||
fi
|
||||
|
||||
cmp --silent $WORKDIR/testfile ./testfile && \
|
||||
cmp --silent $WORKDIR/dir1/testfile1 ./dir1/testfile1 && \
|
||||
cmp --silent $WORKDIR/dir2/testfile2 ./dir2/testfile2
|
||||
if [ $? -ne 0 ]; then
|
||||
echo 'ERROR: file content does not match'
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ ! -d dir001/dir002/dir003 ] || [ ! -d dir004/dir005/dir006 ]; then
|
||||
echo 'ERROR: empty directories are not present'
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
test_resume()
|
||||
{
|
||||
clear_download_area
|
||||
@ -246,6 +279,9 @@ testit "recursive download" test_recursive_U \
|
||||
testit "recursive download (existing target dir)" test_recursive_existing_dir \
|
||||
|| failed=`expr $failed + 1`
|
||||
|
||||
testit "recursive download with empty directories" test_recursive_with_empty \
|
||||
|| failed=`expr $failed + 1`
|
||||
|
||||
testit "resume download" test_resume \
|
||||
|| failed=`expr $failed + 1`
|
||||
|
||||
|
@ -205,6 +205,7 @@ static bool smb_download_dir(const char *base, const char *name, int resume)
|
||||
while ((dirent = smbc_readdir(dirhandle))) {
|
||||
char *newname;
|
||||
if (!strcmp(dirent->name, ".") || !strcmp(dirent->name, "..")) {
|
||||
ok = true;
|
||||
continue;
|
||||
}
|
||||
if (asprintf(&newname, "%s/%s", tmpname, dirent->name) == -1) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user