2023-05-08 Fred Gleason <fredg@paravelsystems.com>

* Added a 'FEEDS.SHA1_HASH' field to the database.
	* Incremented the database version to 368.
	* Added 'RDFeed::sha1Hash()' and 'RDFeed::setSha1Hash()' methods.
	* Added a 'RDSha1HashData()' function.
	* Optimized the podcasting subsystem so as to upload feed XML only
	when the XML contents have actually changed.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2023-05-08 13:23:01 -04:00
parent 1e73e29028
commit afd6a67cd5
15 changed files with 201 additions and 106 deletions

View File

@@ -24,7 +24,7 @@
/*
* Current Database Version
*/
#define RD_VERSION_DATABASE 367
#define RD_VERSION_DATABASE 368
#endif // DBVERSION_H

View File

@@ -713,6 +713,18 @@ void RDFeed::setNormalizeLevel(int lvl) const
}
QString RDFeed::sha1Hash() const
{
return RDGetSqlValue("FEEDS","KEY_NAME",feed_keyname,"SHA1_HASH").toString();
}
void RDFeed::setSha1Hash(const QString &str) const
{
SetRow("SHA1_HASH",str);
}
QByteArray RDFeed::imageData(int img_id) const
{
return RDGetSqlValue("FEED_IMAGES","ID",img_id,"DATA").toByteArray();

View File

@@ -129,6 +129,8 @@ class RDFeed : public QObject
void setUploadMimetype(const QString &str);
int normalizeLevel() const;
void setNormalizeLevel(int lvl) const;
QString sha1Hash() const;
void setSha1Hash(const QString &str) const;
QByteArray imageData(int img_id) const;
int importImageFile(const QString &pathname,QString *err_msg,
QString desc="") const;

View File

@@ -48,6 +48,24 @@ QString __RDSha1Hash_MakePasswordHash(const QString &secret,const QString &salt)
return ret;
}
QString RDSha1HashData(const QByteArray &data)
{
SHA_CTX ctx;
unsigned char md[SHA_DIGEST_LENGTH];
QString ret;
SHA1_Init(&ctx);
SHA1_Update(&ctx,data,data.length());
SHA1_Final(md,&ctx);
for(int i=0;i<SHA_DIGEST_LENGTH;i++) {
ret+=QString::asprintf("%02x",0xff&md[i]);
}
return ret;
}
QString RDSha1HashFile(const QString &filename,bool throttle)
{
QString ret;

View File

@@ -23,6 +23,7 @@
#include <qstring.h>
QString RDSha1HashData(const QByteArray &data);
QString RDSha1HashFile(const QString &filename,bool throttle=false);
QString RDSha1HashPassword(const QString &secret);
bool RDSha1HashCheckPassword(const QString &secret,const QString &hash);