mirror of
https://github.com/HeyPuter/puter
synced 2024-11-14 22:06:00 +00:00
removing storage limit for self hosters
This commit is contained in:
parent
802370eb9d
commit
0da9e1fab3
19
package-lock.json
generated
19
package-lock.json
generated
@ -12,6 +12,7 @@
|
||||
"packages/*"
|
||||
],
|
||||
"dependencies": {
|
||||
"diskusage": "^1.2.0",
|
||||
"uuid": "^9.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -5244,6 +5245,16 @@
|
||||
"md5": "^2.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/diskusage": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/diskusage/-/diskusage-1.2.0.tgz",
|
||||
"integrity": "sha512-2u3OG3xuf5MFyzc4MctNRUKjjwK+UkovRYdD2ed/NZNZPrt0lqHnLKxGhlFVvAb4/oufIgQG3nWgwmeTbHOvXA==",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"es6-promise": "^4.2.8",
|
||||
"nan": "^2.18.0"
|
||||
}
|
||||
},
|
||||
"node_modules/dom-serializer": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz",
|
||||
@ -5481,6 +5492,11 @@
|
||||
"integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/es6-promise": {
|
||||
"version": "4.2.8",
|
||||
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz",
|
||||
"integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w=="
|
||||
},
|
||||
"node_modules/escalade": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz",
|
||||
@ -7889,8 +7905,7 @@
|
||||
"node_modules/nan": {
|
||||
"version": "2.19.0",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.19.0.tgz",
|
||||
"integrity": "sha512-nO1xXxfh/RWNxfd/XPfbIfFk5vgLsAxUR9y5O0cHMJu/AW9U95JLXqthYHjEp+8gQ5p96K9jUp8nbVOxCdRbtw==",
|
||||
"optional": true
|
||||
"integrity": "sha512-nO1xXxfh/RWNxfd/XPfbIfFk5vgLsAxUR9y5O0cHMJu/AW9U95JLXqthYHjEp+8gQ5p96K9jUp8nbVOxCdRbtw=="
|
||||
},
|
||||
"node_modules/napi-build-utils": {
|
||||
"version": "1.0.2",
|
||||
|
@ -39,6 +39,7 @@
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"diskusage": "^1.2.0",
|
||||
"uuid": "^9.0.1"
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
"use strict"
|
||||
const deep_proto_merge = require('./config/deep_proto_merge');
|
||||
// const reserved_words = require('./config/reserved_words');
|
||||
const diskusage = require('diskusage');
|
||||
|
||||
let config = {};
|
||||
|
||||
@ -53,6 +54,17 @@ config.max_subdomains_per_user = 2000;
|
||||
config.storage_capacity = 1*1024*1024*1024;
|
||||
config.static_hosting_domain = '-static.puter.local';
|
||||
|
||||
// Storage limiting is set to false by default
|
||||
// Storage available on the device puter is running is the storage available
|
||||
config.is_storage_limited = false;
|
||||
diskusage.check('/', (err, info) => {
|
||||
if (err) {
|
||||
config.available_device_storage = 1*1024*1024*1024;
|
||||
} else{
|
||||
config.available_device_storage = info.free;
|
||||
}
|
||||
});
|
||||
|
||||
config.thumb_width = 80;
|
||||
config.thumb_height = 80;
|
||||
config.app_max_icon_size = 5*1024*1024;
|
||||
|
@ -23,6 +23,7 @@ const { NodePathSelector, RootNodeSelector } = require("../node/selectors");
|
||||
const { HLFilesystemOperation } = require("./definitions");
|
||||
const { MkTree } = require("./hl_mkdir");
|
||||
const { HLRemove } = require("./hl_remove");
|
||||
const config = require("../../config");
|
||||
|
||||
class HLCopy extends HLFilesystemOperation {
|
||||
static DESCRIPTION = `
|
||||
@ -141,7 +142,7 @@ class HLCopy extends HLFilesystemOperation {
|
||||
let deset_usage = await sizeService.get_usage(dest_user.id);
|
||||
|
||||
const size = await source.fetchSize(values.user);
|
||||
let capacity = (dest_user.free_storage === undefined || dest_user.free_storage === null) ? config.storage_capacity : dest_user.free_storage
|
||||
let capacity = config.is_storage_limited ? (dest_user.free_storage === undefined || dest_user.free_storage === null) ? config.storage_capacity : dest_user.free_storage : config.available_device_storage
|
||||
if(capacity - deset_usage - size < 0){
|
||||
throw APIError.create('storage_limit_reached');
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ const { HLFilesystemOperation } = require("./definitions");
|
||||
const { MkTree } = require("./hl_mkdir");
|
||||
const { HLRemove } = require("./hl_remove");
|
||||
const { TYPE_DIRECTORY } = require("../FSNodeContext");
|
||||
const config = require("../../config");
|
||||
|
||||
class HLMove extends HLFilesystemOperation {
|
||||
static MODULES = {
|
||||
@ -105,7 +106,7 @@ class HLMove extends HLFilesystemOperation {
|
||||
dest_user = source_user;
|
||||
await source.fetchSize();
|
||||
const item_size = source.entry.size;
|
||||
let capacity = (dest_user.free_storage === undefined || dest_user.free_storage === null) ? config.storage_capacity : dest_user.free_storage
|
||||
let capacity = config.is_storage_limited ? (dest_user.free_storage === undefined || dest_user.free_storage === null) ? config.storage_capacity : dest_user.free_storage : config.available_device_storage;
|
||||
if(capacity - await df(dest_user.id) - item_size < 0){
|
||||
throw APIError.create('storage_limit_reached');
|
||||
}
|
||||
|
@ -61,8 +61,8 @@ class WriteCommonTrait {
|
||||
const { file, user } = this.values;
|
||||
|
||||
const usage = await sizeService.get_usage(user.id);
|
||||
let capacity = user.free_storage == undefined
|
||||
? config.storage_capacity : user.free_storage;
|
||||
let capacity = config.is_storage_limited ? user.free_storage == undefined
|
||||
? config.storage_capacity : user.free_storage : config.available_device_storage;
|
||||
if( capacity - usage - file.size < 0 ) {
|
||||
throw APIError.create('storage_limit_reached');
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ router.post('/df', auth, express.json(), async (req, response, next)=>{
|
||||
// auth
|
||||
response.send({
|
||||
used: parseInt(await df(req.user.id)),
|
||||
capacity: (req.user.free_storage === undefined || req.user.free_storage === null) ? config.storage_capacity : req.user.free_storage,
|
||||
capacity: config.is_storage_limited ? (req.user.free_storage === undefined || req.user.free_storage === null) ? config.storage_capacity : req.user.free_storage : config.available_device_storage,
|
||||
});
|
||||
}catch(e){
|
||||
console.log(e)
|
||||
@ -64,7 +64,7 @@ router.get('/df', auth, express.json(), async (req, response, next)=>{
|
||||
// auth
|
||||
response.send({
|
||||
used: parseInt(await df(req.user.id)),
|
||||
capacity: (req.user.free_storage === undefined || req.user.free_storage === null) ? config.storage_capacity : req.user.free_storage,
|
||||
capacity: config.is_storage_limited ? (req.user.free_storage === undefined || req.user.free_storage === null) ? config.storage_capacity : req.user.free_storage : config.available_device_storage,
|
||||
});
|
||||
}catch(e){
|
||||
console.log(e)
|
||||
|
Loading…
Reference in New Issue
Block a user