]> git.sesse.net Git - pr0n/blobdiff - perl/Sesse/pr0n/WebDAV.pm
Unlink all failed uploads.
[pr0n] / 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;
-                       
                        local $dbh->{RaiseError} = 1;
+                       my $fname;
 
                        # Try to insert this new file
                        eval {
@@ -468,7 +468,7 @@ EOF
                                        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: $!";
 
@@ -499,6 +499,7 @@ EOF
                                # Some error occurred, rollback and bomb out
                                $dbh->rollback;
                                dberror($r, "Transaction aborted because $@");
+                               unlink($fname);
                        }
                }