Fix profile covers not working with subfolders
Remove relative_path from the paths saved in the database so they're more portablev1.18.x
parent
33e8ecc1f4
commit
2a0cb3b9ee
@ -0,0 +1,38 @@
|
|||||||
|
/* jslint node: true */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var db = require('../../database');
|
||||||
|
var batch = require('../../batch');
|
||||||
|
|
||||||
|
var async = require('async');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'Remove relative_path from uploaded profile cover urls',
|
||||||
|
timestamp: Date.UTC(2017, 3, 26),
|
||||||
|
method: function (callback) {
|
||||||
|
var progress = this.progress;
|
||||||
|
|
||||||
|
batch.processSortedSet('users:joindate', function (ids, done) {
|
||||||
|
async.each(ids, function (uid, cb) {
|
||||||
|
async.waterfall([
|
||||||
|
function (next) {
|
||||||
|
db.getObjectField('user:' + uid, 'cover:url', next);
|
||||||
|
},
|
||||||
|
function (url, next) {
|
||||||
|
progress.incr();
|
||||||
|
|
||||||
|
if (!url) {
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
|
||||||
|
var newUrl = url.replace(/^.*?\/uploads\//, '/assets/uploads/');
|
||||||
|
db.setObjectField('user:' + uid, 'cover:url', newUrl, next);
|
||||||
|
},
|
||||||
|
], cb);
|
||||||
|
}, done);
|
||||||
|
}, {
|
||||||
|
progress: this.progress,
|
||||||
|
}, callback);
|
||||||
|
},
|
||||||
|
};
|
Loading…
Reference in New Issue