Skip to content
Snippets Groups Projects
Commit 2e821464 authored by deuce's avatar deuce
Browse files

Use a new rename_or_move() function to move files from the temp dir to the

inbound dir.
parent 587bece6
No related branches found
No related tags found
No related merge requests found
......@@ -314,6 +314,44 @@ function handle_freq(reqfname, bp)
}
}
function rename_or_move(src, dst)
{
var sf;
var df;
var buf;
var remain;
if (file_rename(src, dst))
return true;
sf = new File(src);
if (!sf.open("rb"))
return false;
df = new File(dst);
if (!df.open("web")) {
sf.close();
return false;
}
while (!sf.eof) {
// Read 2MB at a time...
remain = sf.length - sf.position;
if (remain === 0)
break;
if (remain > 0x200000)
remain = 0x200000;
buf = sf.read(remain);
if (!df.write(buf)) {
df.close();
df.remove();
sf.close();
return false;
}
}
df.close();
sf.close();
sf.remove();
return true;
}
function rx_callback(fname, bp)
{
var semname;
......@@ -336,12 +374,12 @@ function rx_callback(fname, bp)
else {
if (bp.authenticated === 'secure') {
log(LOG_INFO, "Moving '"+fname+"' to '"+bp.cb_data.binkit_scfg.secure_inbound+file_getname(fname)+"'.");
if (!file_rename(fname, bp.cb_data.binkit_scfg.secure_inbound+file_getname(fname)))
if (!rename_or_move(fname, bp.cb_data.binkit_scfg.secure_inbound+file_getname(fname)))
return false;
}
else {
log(LOG_INFO, "Moving '"+fname+"' to '"+bp.cb_data.binkit_scfg.inbound+file_getname(fname)+"'.");
if (!file_rename(fname, bp.cb_data.binkit_scfg.inbound+file_getname(fname)))
if (!rename_or_move(fname, bp.cb_data.binkit_scfg.inbound+file_getname(fname)))
return false;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment