]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/API2/Storage/Status.pm
file upload: fix race condition
[pve-storage.git] / PVE / API2 / Storage / Status.pm
index fda54bb04e85b32e63f522e068109c553107581c..09222298131aaf1fc05b346f3dd533fa9795f404 100644 (file)
@@ -378,7 +378,14 @@ __PACKAGE__->register_method ({
            print "finished file import successfully\n";
        };
 
-       return $rpcenv->fork_worker('imgcopy', undef, $user, $worker);
+       my $upid = $rpcenv->fork_worker('imgcopy', undef, $user, $worker);
+
+       # apache removes the temporary file on return, so we need
+       # to wait here to make sure the worker process starts and
+       # opens the file before it gets removed.
+       sleep(1);
+
+       return $upid;
    }});
     
 1;