Title a subdirectory scan may "loose" files outside that subdirectory
Priority bug Status resolved
Superseder Nosy List poeml
Assigned To poeml Keywords

Created on 2009-10-30.12:11:53 by poeml, last changed by poeml.

msg44 (view) Author: poeml Date: 2009-10-30.12:11:52
The list of filenames that is grabbed at the beginning of a "subdirectory scan" ('mb scan -d DIR') is too broad. It uses a string prefix 
match that isn't terminated with a trailing slash. Thus, a scan in "factory" grabs also files in "factory-snapshot". This leads to 
deletion of all the files outside of the directory at the end of the scan.

(The deletion is supposed to happen only for the files that have disappeared in the given subdirectory; this is implemented by copying 
the list of known files into a temporary database table at the beginning, and each file that is seen on the mirror during scanning is 
removed from that table. All remaining files are deleted in the end. Thus, if too many files are grabbed in the beginning, they'll be 
deleted, too.)

The problem is here:

> 277     if(length $start_dir) {
> 278       $sql = "CREATE TEMPORARY TABLE temp1 AS 
> 279               SELECT id FROM filearr 
> 280               WHERE path LIKE '$start_dir%' 
> 281                     AND $row->{id} = ANY(mirrors)";

The LIKE expression needs be changed to '$start_dir/%'.
msg45 (view) Author: poeml Date: 2009-10-30.12:12:50
The fix is successfully tested in openSUSE's setup, where the bug was noticed
msg46 (view) Author: poeml Date: 2009-10-30.12:18:12
Fixed in trunk
msg48 (view) Author: poeml Date: 2009-11-04.19:04:02
Fixed with the 2.10.2 release.
Date User Action Args
2009-11-04 19:04:02poemlsetstatus: testing -> resolved
messages: + msg48
2009-10-30 12:18:12poemlsetmessages: + msg46
2009-10-30 12:12:50poemlsetmessages: + msg45
2009-10-30 12:11:59poemlsetstatus: unread -> testing
2009-10-30 12:11:53poemlcreate