Use the system temporary directory for packed content
This commit is contained in:
parent
d58dda6f50
commit
32e2582ded
|
@ -4,6 +4,7 @@ dist
|
|||
etc
|
||||
release
|
||||
|
||||
tests/tmp
|
||||
tests/log.txt
|
||||
|
||||
# User data
|
||||
|
|
|
@ -65,6 +65,10 @@ export default class Content extends AsyncEventEmitter {
|
|||
get config() { return this.settings.categories }
|
||||
get data() { return this.userConfig.data || (this.userConfig.data = {}) }
|
||||
|
||||
get packed() { return this.dirName.packed }
|
||||
get packagePath() { return this.dirName.packagePath }
|
||||
get packageName() { return this.dirName.pkg }
|
||||
|
||||
/**
|
||||
* Opens a settings modal for this content.
|
||||
* @return {Modal}
|
||||
|
|
|
@ -220,6 +220,7 @@ export default class {
|
|||
const unpackedPath = path.join(Globals.getPath('tmp'), packageName);
|
||||
|
||||
asar.extractAll(packagePath, unpackedPath);
|
||||
|
||||
return this.preloadContent({
|
||||
config,
|
||||
contentPath: unpackedPath,
|
||||
|
@ -228,8 +229,8 @@ export default class {
|
|||
packageName,
|
||||
packed: true
|
||||
}, reload, index);
|
||||
|
||||
} catch (err) {
|
||||
Logger.log('ContentManager', ['Error extracting packed content', err]);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
@ -322,12 +323,6 @@ export default class {
|
|||
return content;
|
||||
} catch (err) {
|
||||
throw err;
|
||||
} finally {
|
||||
if (typeof dirName === 'object' && dirName.packed) {
|
||||
rimraf(dirName.contentPath, err => {
|
||||
if (err) Logger.err(err);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -353,6 +348,7 @@ export default class {
|
|||
await unload;
|
||||
|
||||
await FileUtils.recursiveDeleteDirectory(content.paths.contentPath);
|
||||
if (content.packed) await FileUtils.recursiveDeleteDirectory(content.packagePath);
|
||||
return true;
|
||||
} catch (err) {
|
||||
Logger.err(this.moduleName, err);
|
||||
|
@ -384,7 +380,7 @@ export default class {
|
|||
|
||||
if (this.unloadContentHook) this.unloadContentHook(content);
|
||||
|
||||
if (reload) return content.packed ? this.preloadPackedContent(content.packed.pkg, true, index) : this.preloadContent(content.dirName, true, index);
|
||||
if (reload) return content.packed ? this.preloadPackedContent(content.packagePath, true, index) : this.preloadContent(content.dirName, true, index);
|
||||
|
||||
this.localContent.splice(index, 1);
|
||||
} catch (err) {
|
||||
|
|
|
@ -36,10 +36,6 @@ export default new class extends Module {
|
|||
|
||||
async first() {
|
||||
const config = await ClientIPC.send('getConfig');
|
||||
config.paths.push({
|
||||
id: 'tmp',
|
||||
path: path.join(config.paths.find(p => p.id === 'base').path, 'tmp')
|
||||
});
|
||||
this.setState({ config });
|
||||
|
||||
// This is for Discord to stop error reporting :3
|
||||
|
|
|
@ -35,12 +35,16 @@ const TEST_ARGS = () => {
|
|||
'client': path.resolve(_basePath, 'client', 'dist'),
|
||||
'core': path.resolve(_basePath, 'core', 'dist'),
|
||||
'data': path.resolve(_baseDataPath, 'data'),
|
||||
'editor': path.resolve(_basePath, 'editor', 'dist')
|
||||
'editor': path.resolve(_basePath, 'editor', 'dist'),
|
||||
// tmp: path.join(_basePath, 'tmp')
|
||||
tmp: path.join(os.tmpdir(), 'betterdiscord', `${process.getuid()}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
const TEST_EDITOR = TESTS && true;
|
||||
|
||||
import process from 'process';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import sass from 'node-sass';
|
||||
import { BrowserWindow as OriginalBrowserWindow, dialog, session, shell } from 'electron';
|
||||
|
|
Loading…
Reference in New Issue