Item13568: tools/bulk_copy.pl: removes topic data prior to saving new revision; breaks attachments and history
Priority: Urgent
Current State: Closed
Released In: 2.0.1
Target Release: patch
bulk_copy.pl
iterates over topic revisions and performs a save for each revision. When doing that, it checks whether the topic already exists in the target instance (which it does after the first revision has been saved there) -- if so, it is deleted, including all attachments. Code in question, from
saveTopicRev
, included since the first committed revision of
bulk_copy.pl
:
[...]
# When saving over existing revs of a topic, must make sure we
# fully delete the existing data
if ( $session->topicExists( $web, $topic ) ) {
my $demo = Foswiki::Meta->new( $session, $web, $topic );
$demo->removeFromStore();
[...]
Let's assume you have a topic with the following history:
- Revision 1: text, uploaded an attachment
- Revision 2: changed text, did not touch attachment
So, this saves revision 1, then deletes the topic before saving revision 2. The result is a topic with one revision (equivalent to revision 2 in the origin instance) and no attachment data (because revision 2 did not include any new revisions of an attachment).
I'm not entirely sure the delete needs to be in there at all -- after all,
bulk_copy.pl
skips existing topics no matter what.
--
JanKrueger - 28 Jul 2015
Yes, the situation i was trying to avoid is where Topic revs 1..3 are saved over Topic where it already has revs 1..3 from a previous copy, as the new revs would then be 4..6 instead.
Your patch looks correct to me. Go ahead.
--
Main.CrawfordCurrie - 30 Jul 2015 - 14:12