The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/server/startup/migrations/v042.coffee

31 lines
1.0 KiB

RocketChat.Migrations.add
version: 42
up: ->
files = RocketChat.__migration_assets_files = new Mongo.Collection('assets.files')
chunks = RocketChat.__migration_assets_chunks = new Mongo.Collection('assets.chunks')
list = {
'favicon.ico': 'favicon_ico'
'favicon.svg': 'favicon'
'favicon_64.png': 'favicon_64'
'favicon_96.png': 'favicon_96'
'favicon_128.png': 'favicon_128'
'favicon_192.png': 'favicon_192'
'favicon_256.png': 'favicon_256'
}
for from, to of list
if not files.findOne({_id: to})?
oldFile = files.findOne({_id: from})
if oldFile?
extension = RocketChat.Assets.mime.extension(oldFile.contentType)
RocketChat.settings.removeById "Assets_#{from}"
RocketChat.settings.updateById "Assets_#{to}", {
url: "/assets/#{to}.#{extension}"
defaultUrl: RocketChat.Assets.assets[to].defaultUrl
}
oldFile._id = to
oldFile.filename = to
files.insert(oldFile)
files.remove({_id: from})
chunks.update({files_id: from}, {$set: {files_id: to}}, {multi: true})