mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-11-30 12:14:36 -05:00
fix: stop zmfilter treating a failed FTP or SFTP upload as done fixes #5574
This commit is contained in:
1 parent
02a0dfc872
commit
eb6890911b
1 file changed
+35
-14
+35
-14
@@ -610,6 +610,7 @@ sub uploadArchFile {
|
||||
}
|
||||
|
||||
if ( $archError ) {
|
||||
unlink($archLocPath);
|
||||
return 0;
|
||||
} else {
|
||||
if ( $Config{ZM_UPLOAD_PROTOCOL} eq 'ftp' ) {
|
||||
@@ -624,15 +625,30 @@ sub uploadArchFile {
|
||||
Error("Unable to create FTP connection: $@");
|
||||
return 0;
|
||||
}
|
||||
$ftp->login($Config{ZM_UPLOAD_USER}, $Config{ZM_UPLOAD_PASS})
|
||||
or Error("FTP - Unable to login");
|
||||
$ftp->binary()
|
||||
or Error("FTP - Unable to go binary");
|
||||
$ftp->cwd($Config{ZM_UPLOAD_REM_DIR})
|
||||
or Error("FTP - Unable to cwd")
|
||||
if ( $Config{ZM_UPLOAD_REM_DIR} );
|
||||
$ftp->put( $archLocPath )
|
||||
or Error("FTP - Unable to upload '$archLocPath'");
|
||||
if ( !$ftp->login($Config{ZM_UPLOAD_USER}, $Config{ZM_UPLOAD_PASS}) ) {
|
||||
Error("FTP - Unable to login: ".$ftp->message);
|
||||
$ftp->quit();
|
||||
unlink($archLocPath);
|
||||
return 0;
|
||||
}
|
||||
if ( !$ftp->binary() ) {
|
||||
Error("FTP - Unable to go binary: ".$ftp->message);
|
||||
$ftp->quit();
|
||||
unlink($archLocPath);
|
||||
return 0;
|
||||
}
|
||||
if ( $Config{ZM_UPLOAD_REM_DIR} and !$ftp->cwd($Config{ZM_UPLOAD_REM_DIR}) ) {
|
||||
Error("FTP - Unable to cwd: ".$ftp->message);
|
||||
$ftp->quit();
|
||||
unlink($archLocPath);
|
||||
return 0;
|
||||
}
|
||||
if ( !$ftp->put( $archLocPath ) ) {
|
||||
Error("FTP - Unable to upload '$archLocPath': ".$ftp->message);
|
||||
$ftp->quit();
|
||||
unlink($archLocPath);
|
||||
return 0;
|
||||
}
|
||||
$ftp->quit()
|
||||
or Error("FTP - Unable to quit");
|
||||
} else {
|
||||
@@ -657,11 +673,16 @@ sub uploadArchFile {
|
||||
Error("Unable to create SFTP connection: ".$sftp->error);
|
||||
return 0;
|
||||
}
|
||||
$sftp->setcwd($Config{ZM_UPLOAD_REM_DIR})
|
||||
or Error("SFTP - Unable to setcwd: ".$sftp->error)
|
||||
if $Config{ZM_UPLOAD_REM_DIR};
|
||||
$sftp->put($archLocPath, $archFile)
|
||||
or Error("SFTP - Unable to upload '$archLocPath': ".$sftp->error);
|
||||
if ( $Config{ZM_UPLOAD_REM_DIR} and !$sftp->setcwd($Config{ZM_UPLOAD_REM_DIR}) ) {
|
||||
Error("SFTP - Unable to setcwd: ".$sftp->error);
|
||||
unlink($archLocPath);
|
||||
return 0;
|
||||
}
|
||||
if ( !$sftp->put($archLocPath, $archFile) ) {
|
||||
Error("SFTP - Unable to upload '$archLocPath': ".$sftp->error);
|
||||
unlink($archLocPath);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
unlink($archLocPath);
|
||||
zmDbExecute('UPDATE `Events` SET `Uploaded`=1 WHERE `Id`=?', $Event->{Id});
|
||||
|
||||
Reference in new issue
Block a user