Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1 Move instead of copy

closed-accepted
nobody
None
5
2006-07-21
2006-06-04
Anonymous
No

Hey I've found (and fixed) a minor error in your
webinterface. In functions.php around line 76, you
perform a 'copy' on the nzb file uploaded to the tempdir.
However a copy takes time to do and hellanzb sometimes
notices the file while it's being copied, and thus
rejects an incomplete NZB.
I've attached a fixed version of the file that uses a
unix 'mv' to get the file in the queue dir. "mv" just
alters the inode of the file so it appears instantly.
You may still need to make sure that the tmpdir and
the queuedir are on the same partition.

Regards,
Marius Karthaus
www.budgetdedicated.com

Discussion

  • functions.php with mv instead of copy

     
    Attachments
  • Logged In: NO

    I've fixed the "tmpdir must be on the same partition"
    problem my previous patch has (I guess a lot of people will
    not have their php tmpdir on the same partition so it was
    not a very general fix)
    And I've added some more checking and cleaner code. Here it is:

    // ************************************************
    // ********* Upload file functions ****************
    // ************************************************
    function upload_file ($nzb_file) {

    global $download_nzb_path;
    if (! is_writeable($download_nzb_path)){
    $error="queue dir $download_nzb_path is not writeable!";
    return $error;
    }
    if (! is_dir($download_nzb_path.'/tmp/')){
    mkdir ($download_nzb_path."/tmp/");
    }
    $error = validate_upload($nzb_file);
    if ($error) {
    return ($error);
    } else { # cool, we can continue
    # (Marius Karthaus, www.budgetdedicated.com)
    # first move the nzb file to the same partition
    # than move the nzb file into the queue
    # why? move on the same partition just changes the
    INODE,
    # copy may fail because hellanzb checks (and
    rejects) the file while copy in still in progress
    $command="mv
    ".escapeshellarg($nzb_file['tmp_name'])."
    ".escapeshellarg($download_nzb_path."/tmp/".$nzb_file['name']$
    exec($command,$res,$ret);
    if ($ret>0){
    $error="Could not move the tmpfile to the target
    partition";
    return $error;
    }
    $command="mv
    ".escapeshellarg($download_nzb_path."/tmp/".$nzb_file['name'])."
    ".escapeshellarg($download_nzb_path.$n$
    exec($command,$res,$ret);
    if ($ret>0){
    $error="Could not move the nzb to the queuedir";
    return $error;
    }
    $error = "<br><br><b><font color=\"#00FF00\">File
    upload OK </font></b><br>
    Filename: " . $nzb_file['name'] ."<br>
    Filesize: " . $nzb_file['size'] ."
    <br>";
    }
    return ($error);
    } # END upload

     
  • macaroon
    macaroon
    2006-07-02

    Logged In: YES
    user_id=1441383

    Marius,

    Thanks for this fix. I'll test it one day soon and put it
    in the source.

    Jos

     
  • macaroon
    macaroon
    2006-07-21

    • status: open --> closed-accepted