29 lines
804 B
JavaScript
29 lines
804 B
JavaScript
const TASK = {
|
|
key: 'initial-media-sync',
|
|
category: 'media-sync',
|
|
};
|
|
|
|
function registerInitialMediaSyncTask(options) {
|
|
const backgroundTaskQueue = options && options.backgroundTaskQueue;
|
|
const mediaDir = String(options && options.mediaDir || '').trim();
|
|
|
|
if (!backgroundTaskQueue || !mediaDir) {
|
|
throw new Error('registerInitialMediaSyncTask requires the initial media sync dependencies.');
|
|
}
|
|
|
|
return backgroundTaskQueue.enqueueTask({
|
|
key: TASK.key,
|
|
title: 'Initial media sync',
|
|
category: TASK.category,
|
|
taskType: 'media-sync',
|
|
payload: {
|
|
mode: 'initial',
|
|
uploadDir: mediaDir
|
|
},
|
|
persist: true
|
|
}).catch(function (error) {
|
|
console.warn('Unable to queue initial media sync:', error);
|
|
});
|
|
}
|
|
|
|
module.exports = { registerInitialMediaSyncTask }; |