2023-04-12 Fred Gleason <fredg@paravelsystems.com>

* Added a 'RDUpload::createDestinationDirs()' method.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2023-04-12 10:16:23 -04:00
parent d3a7cef2a8
commit 423e2b0e81
5 changed files with 29 additions and 3 deletions

View File

@@ -24021,3 +24021,5 @@
* Refactored code in rdrssd(8) to improve reliability.
2023-03-24 Fred Gleason <fredg@paravelsystems.com>
* Incremented the package version to 4.0.0rc2int0.
2023-04-12 Fred Gleason <fredg@paravelsystems.com>
* Added a 'RDUpload::createDestinationDirs()' method.

View File

@@ -76,6 +76,7 @@ RDUpload::RDUpload(RDConfig *c,QObject *parent)
: RDTransfer(c,parent)
{
conv_aborting=false;
conv_create_dst_dirs=false;
}
@@ -106,6 +107,12 @@ void RDUpload::setDestinationUrl(const QString &url)
}
void RDUpload::createDestinationDirs(bool state)
{
conv_create_dst_dirs=state;
}
int RDUpload::totalSteps() const
{
return conv_src_size;
@@ -178,6 +185,14 @@ RDUpload::ErrorCode RDUpload::runUpload(const QString &username,
}
curl_easy_setopt(curl,CURLOPT_SSL_VERIFYHOST,0); // Don't verify host key
//
// Create any needed target directories
//
if(conv_create_dst_dirs) {
curl_easy_setopt(curl,CURLOPT_FTP_CREATE_MISSING_DIRS,
CURLFTP_CREATE_DIR_RETRY);
}
//
// Transfer Parameters
//

View File

@@ -39,6 +39,7 @@ class RDUpload : public RDTransfer
QStringList supportedSchemes() const;
void setSourceFile(const QString &filename);
void setDestinationUrl(const QString &url);
void createDestinationDirs(bool state);
int totalSteps() const;
RDUpload::ErrorCode runUpload(const QString &username,
const QString &password,
@@ -62,6 +63,7 @@ class RDUpload : public RDTransfer
double ulnow);
QString conv_src_filename;
QUrl conv_dst_url;
bool conv_create_dst_dirs;
bool conv_aborting;
uint conv_src_size;
};

View File

@@ -2,7 +2,7 @@
//
// Test Rivendell file uploading.
//
// (C) Copyright 2010-2022 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2010-2023 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -36,6 +36,7 @@ MainObject::MainObject(QObject *parent)
password="";
RDUpload::ErrorCode conv_err;
use_identity_file=false;
create_dirs=false;
//
// Open the Database
@@ -66,6 +67,10 @@ MainObject::MainObject(QObject *parent)
use_identity_file=true;
rda->cmdSwitch()->setProcessed(i,true);
}
if(rda->cmdSwitch()->key(i)=="--create-dirs") {
create_dirs=true;
rda->cmdSwitch()->setProcessed(i,true);
}
if(rda->cmdSwitch()->key(i)=="--source-file") {
source_filename=rda->cmdSwitch()->value(i);
rda->cmdSwitch()->setProcessed(i,true);
@@ -100,6 +105,7 @@ MainObject::MainObject(QObject *parent)
RDUpload *conv=new RDUpload(rda->config(),this);
conv->setSourceFile(source_filename);
conv->setDestinationUrl(destination_url);
conv->createDestinationDirs(create_dirs);
printf("Uploading...\n");
conv_err=conv->
runUpload(username,password,ssh_identity_filename,use_identity_file,

View File

@@ -2,7 +2,7 @@
//
// Test Rivendell file uploading
//
// (C) Copyright 2010,2016-2018 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2010-2023 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -25,7 +25,7 @@
#include <qobject.h>
#define UPLOAD_TEST_USAGE "[options]\n\nTest the Rivendell upload routines\n\nOptions are:\n--username=<username>\n\n--password=<password>\n\n--ssh-identity-key=<filename>\n\n--use-identity-file=y|n\n\n--source-file=<filename>\n\n--destination-url=<url>\n\n"
#define UPLOAD_TEST_USAGE "[options]\n\nTest the Rivendell upload routines\n\nOptions are:\n--username=<username>\n\n--password=<password>\n\n--ssh-identity-key=<filename>\n\n--use-identity-file=y|n\n\n--create-dirs\n\n--source-file=<filename>\n\n--destination-url=<url>\n\n"
class MainObject : public QObject
{
@@ -35,6 +35,7 @@ class MainObject : public QObject
private:
QString username;
QString password;
bool create_dirs;
QString source_filename;
QString destination_url;
QString ssh_identity_filename;