Fix: Error thrown in folder migration if new and old path are same

This commit is contained in:
Skylar Sadlier 2022-04-19 12:58:52 -06:00
parent 97f27e61c6
commit 5ef0b6a11f

View File

@ -5,8 +5,6 @@ const { resolve } = require('path');
const { LocalStorage } = require('node-localstorage'); const { LocalStorage } = require('node-localstorage');
const { LocalStorageCryptoStore } = require('matrix-js-sdk/lib/crypto/store/localStorage-crypto-store'); const { LocalStorageCryptoStore } = require('matrix-js-sdk/lib/crypto/store/localStorage-crypto-store');
const {RoomEvent, RoomMemberEvent, HttpApiEvent, ClientEvent} = require("matrix-js-sdk"); const {RoomEvent, RoomMemberEvent, HttpApiEvent, ClientEvent} = require("matrix-js-sdk");
const {deriveKey} = require("matrix-js-sdk/lib/crypto/key_passphrase");
const {encryptAES} = require("matrix-js-sdk/lib/crypto/aes");
module.exports = function(RED) { module.exports = function(RED) {
function MatrixFolderNameFromUserId(name) { function MatrixFolderNameFromUserId(name) {
@ -466,7 +464,7 @@ module.exports = function(RED) {
fs.renameSync(oldStorageDir, oldStorageDir + "-backup"); fs.renameSync(oldStorageDir, oldStorageDir + "-backup");
} }
if(RED.settings.userDir !== resolve('./')) { if(RED.settings.userDir !== resolve('./') && resolve(oldStorageDir2) !== resolve(storageDir)) {
// user directory does not match running directory // user directory does not match running directory
// check if we stored stuff in wrong directory and move it // check if we stored stuff in wrong directory and move it
if(fs.pathExistsSync(oldStorageDir2)){ if(fs.pathExistsSync(oldStorageDir2)){