Skip to content

Commit

Permalink
Subscription metadata fix (#934)
Browse files Browse the repository at this point in the history
* Fixed issue where metadata was attempting to be written to a dir that didn't exist yet
* Fixed issue where sub was assumed as duplicate always if using local db
  • Loading branch information
Tzahi12345 authored May 27, 2023
1 parent f23ca61 commit 13a03a7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion backend/subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ exports.subscribe = async (sub, user_uid = null, skip_get_info = false) => {
}

sub['user_uid'] = user_uid ? user_uid : undefined;
await db_api.insertRecordIntoTable('subscriptions', sub);
await db_api.insertRecordIntoTable('subscriptions', JSON.parse(JSON.stringify(sub)));

let success = skip_get_info ? true : await getSubscriptionInfo(sub);
exports.writeSubscriptionMetadata(sub);
Expand Down Expand Up @@ -491,6 +491,8 @@ exports.writeSubscriptionMetadata = (sub) => {
: config_api.getConfigItem('ytdl_subscriptions_base_path');
const appendedBasePath = getAppendedBasePath(sub, basePath);
const metadata_path = path.join(appendedBasePath, CONSTS.SUBSCRIPTION_BACKUP_PATH);

fs.ensureDirSync(appendedBasePath);
fs.writeJSONSync(metadata_path, sub);
}

Expand Down

0 comments on commit 13a03a7

Please sign in to comment.