Unlink all failed uploads.
authorSteinar H. Gunderson <sesse@debian.org>
Wed, 9 Aug 2006 21:40:35 +0000 (23:40 +0200)
committerSteinar H. Gunderson <sesse@debian.org>
Wed, 9 Aug 2006 21:40:35 +0000 (23:40 +0200)
perl/Sesse/pr0n/WebDAV.pm

index 2a974e2a9eed47f47dbbdadcc0ca77701786fd76..08f4c7ba57ca34b7e5eb53b201acc8a8c8ce5aa9 100644 (file)
@@ -456,8 +456,8 @@ EOF
                {
                        # Enable transactions and error raising temporarily
                        local $dbh->{AutoCommit} = 0;
                {
                        # Enable transactions and error raising temporarily
                        local $dbh->{AutoCommit} = 0;
-                       
                        local $dbh->{RaiseError} = 1;
                        local $dbh->{RaiseError} = 1;
+                       my $fname;
 
                        # Try to insert this new file
                        eval {
 
                        # Try to insert this new file
                        eval {
@@ -468,7 +468,7 @@ EOF
                                        undef, $newid, $event, $user, $takenby, $filename);
 
                                # Now save the file to disk
                                        undef, $newid, $event, $user, $takenby, $filename);
 
                                # Now save the file to disk
-                               my $fname = Sesse::pr0n::Common::get_disk_location($r, $newid);
+                               $fname = Sesse::pr0n::Common::get_disk_location($r, $newid);
                                open NEWFILE, ">$fname"
                                        or die "$fname: $!";
 
                                open NEWFILE, ">$fname"
                                        or die "$fname: $!";
 
@@ -499,6 +499,7 @@ EOF
                                # Some error occurred, rollback and bomb out
                                $dbh->rollback;
                                dberror($r, "Transaction aborted because $@");
                                # Some error occurred, rollback and bomb out
                                $dbh->rollback;
                                dberror($r, "Transaction aborted because $@");
+                               unlink($fname);
                        }
                }
 
                        }
                }