Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

feat(backend/frontend): support quota definition and usage for shares with external paths, and include storage usage from external-path space roots in the total space usage

johaven0b08004a3a60
diff --git a/backend/migrations/0004_soft_sphinx.sql b/backend/migrations/0004_soft_sphinx.sql
new file mode 100644
index 00000000..15952428
--- /dev/null
+++ b/backend/migrations/0004_soft_sphinx.sql
@@ -0,0 +1,3 @@
+ALTER TABLE `shares` ADD `storageUsage` bigint unsigned DEFAULT 0 NOT NULL;--> statement-breakpoint
+ALTER TABLE `shares` ADD `storageQuota` bigint unsigned;--> statement-breakpoint
+ALTER TABLE `shares` ADD `storageIndexing` boolean DEFAULT true NOT NULL;
\ No newline at end of file
diff --git a/backend/migrations/meta/0004_snapshot.json b/backend/migrations/meta/0004_snapshot.json
new file mode 100644
index 00000000..458d6a47
--- /dev/null
+++ b/backend/migrations/meta/0004_snapshot.json
@@ -0,0 +1,2463 @@
+{
+ "version": "5",
+ "dialect": "mysql",
+ "id": "96aa812c-d329-429d-9d0e-e54bc26ae093",
+ "prevId": "ffa22779-d12a-4b0e-9aed-657e020cc05d",
+ "tables": {
+ "cache": {
+ "name": "cache",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "varchar(768)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "value": {
+ "name": "value",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "expiration": {
+ "name": "expiration",
+ "type": "int",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": -1
+ }
+ },
+ "indexes": {
+ "expiration_idx": {
+ "name": "expiration_idx",
+ "columns": [
+ "expiration"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "cache_key": {
+ "name": "cache_key",
+ "columns": [
+ "key"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "users": {
+ "name": "users",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "email": {
+ "name": "email",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "login": {
+ "name": "login",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "firstName": {
+ "name": "firstName",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "lastName": {
+ "name": "lastName",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "password": {
+ "name": "password",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "passwordAttempts": {
+ "name": "passwordAttempts",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "role": {
+ "name": "role",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 1
+ },
+ "isActive": {
+ "name": "isActive",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "secrets": {
+ "name": "secrets",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "language": {
+ "name": "language",
+ "type": "char(2)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "storageUsage": {
+ "name": "storageUsage",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 0
+ },
+ "storageQuota": {
+ "name": "storageQuota",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "storageIndexing": {
+ "name": "storageIndexing",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "notification": {
+ "name": "notification",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 1
+ },
+ "onlineStatus": {
+ "name": "onlineStatus",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "currentIp": {
+ "name": "currentIp",
+ "type": "varchar(45)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "lastIp": {
+ "name": "lastIp",
+ "type": "varchar(45)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "currentAccess": {
+ "name": "currentAccess",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "lastAccess": {
+ "name": "lastAccess",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "email_idx": {
+ "name": "email_idx",
+ "columns": [
+ "email"
+ ],
+ "isUnique": true
+ },
+ "login_idx": {
+ "name": "login_idx",
+ "columns": [
+ "login"
+ ],
+ "isUnique": true
+ },
+ "role_idx": {
+ "name": "role_idx",
+ "columns": [
+ "role"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "users_id": {
+ "name": "users_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "groups": {
+ "name": "groups",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "parentId": {
+ "name": "parentId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "name_idx": {
+ "name": "name_idx",
+ "columns": [
+ "name"
+ ],
+ "isUnique": true
+ },
+ "parent_idx": {
+ "name": "parent_idx",
+ "columns": [
+ "parentId"
+ ],
+ "isUnique": false
+ },
+ "type_idx": {
+ "name": "type_idx",
+ "columns": [
+ "type"
+ ],
+ "isUnique": false
+ },
+ "visibility_idx": {
+ "name": "visibility_idx",
+ "columns": [
+ "visibility"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "groups_parentId_groups_id_fk": {
+ "name": "groups_parentId_groups_id_fk",
+ "tableFrom": "groups",
+ "tableTo": "groups",
+ "columnsFrom": [
+ "parentId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "groups_id": {
+ "name": "groups_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "users_groups": {
+ "name": "users_groups",
+ "columns": {
+ "userId": {
+ "name": "userId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "groupId": {
+ "name": "groupId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "user_idx": {
+ "name": "user_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "group_idx": {
+ "name": "group_idx",
+ "columns": [
+ "groupId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "users_groups_userId_users_id_fk": {
+ "name": "users_groups_userId_users_id_fk",
+ "tableFrom": "users_groups",
+ "tableTo": "users",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "users_groups_groupId_groups_id_fk": {
+ "name": "users_groups_groupId_groups_id_fk",
+ "tableFrom": "users_groups",
+ "tableTo": "groups",
+ "columnsFrom": [
+ "groupId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "users_groups_userId_groupId_pk": {
+ "name": "users_groups_userId_groupId_pk",
+ "columns": [
+ "userId",
+ "groupId"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "users_guests": {
+ "name": "users_guests",
+ "columns": {
+ "userId": {
+ "name": "userId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "guestId": {
+ "name": "guestId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "user_idx": {
+ "name": "user_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "guest_id": {
+ "name": "guest_id",
+ "columns": [
+ "guestId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "users_guests_userId_users_id_fk": {
+ "name": "users_guests_userId_users_id_fk",
+ "tableFrom": "users_guests",
+ "tableTo": "users",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "users_guests_guestId_users_id_fk": {
+ "name": "users_guests_guestId_users_id_fk",
+ "tableFrom": "users_guests",
+ "tableTo": "users",
+ "columnsFrom": [
+ "guestId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "users_guests_userId_guestId_pk": {
+ "name": "users_guests_userId_guestId_pk",
+ "columns": [
+ "userId",
+ "guestId"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {
+ "user_guest_check": {
+ "name": "user_guest_check",
+ "value": "`users_guests`.`userId` <> `users_guests`.`guestId`"
+ }
+ }
+ },
+ "spaces": {
+ "name": "spaces",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "alias": {
+ "name": "alias",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "storageUsage": {
+ "name": "storageUsage",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "storageQuota": {
+ "name": "storageQuota",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "storageIndexing": {
+ "name": "storageIndexing",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
+ },
+ "disabledAt": {
+ "name": "disabledAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "alias_idx": {
+ "name": "alias_idx",
+ "columns": [
+ "alias"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "spaces_id": {
+ "name": "spaces_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "spaces_members": {
+ "name": "spaces_members",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "spaceId": {
+ "name": "spaceId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "groupId": {
+ "name": "groupId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "linkId": {
+ "name": "linkId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "varchar(32)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "space_idx": {
+ "name": "space_idx",
+ "columns": [
+ "spaceId"
+ ],
+ "isUnique": false
+ },
+ "user_idx": {
+ "name": "user_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "group_idx": {
+ "name": "group_idx",
+ "columns": [
+ "groupId"
+ ],
+ "isUnique": false
+ },
+ "link_idx": {
+ "name": "link_idx",
+ "columns": [
+ "linkId"
+ ],
+ "isUnique": false
+ },
+ "role_idx": {
+ "name": "role_idx",
+ "columns": [
+ "role"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "spaces_members_spaceId_spaces_id_fk": {
+ "name": "spaces_members_spaceId_spaces_id_fk",
+ "tableFrom": "spaces_members",
+ "tableTo": "spaces",
+ "columnsFrom": [
+ "spaceId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "spaces_members_userId_users_id_fk": {
+ "name": "spaces_members_userId_users_id_fk",
+ "tableFrom": "spaces_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "spaces_members_groupId_groups_id_fk": {
+ "name": "spaces_members_groupId_groups_id_fk",
+ "tableFrom": "spaces_members",
+ "tableTo": "groups",
+ "columnsFrom": [
+ "groupId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "spaces_members_linkId_links_id_fk": {
+ "name": "spaces_members_linkId_links_id_fk",
+ "tableFrom": "spaces_members",
+ "tableTo": "links",
+ "columnsFrom": [
+ "linkId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "spaces_members_id": {
+ "name": "spaces_members_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {
+ "space_user_uniq": {
+ "name": "space_user_uniq",
+ "columns": [
+ "spaceId",
+ "userId"
+ ]
+ },
+ "space_group_uniq": {
+ "name": "space_group_uniq",
+ "columns": [
+ "spaceId",
+ "groupId"
+ ]
+ },
+ "space_link_uniq": {
+ "name": "space_link_uniq",
+ "columns": [
+ "spaceId",
+ "linkId"
+ ]
+ }
+ },
+ "checkConstraint": {}
+ },
+ "spaces_roots": {
+ "name": "spaces_roots",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "spaceId": {
+ "name": "spaceId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "fileId": {
+ "name": "fileId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "alias": {
+ "name": "alias",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "externalPath": {
+ "name": "externalPath",
+ "type": "varchar(4096)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "varchar(32)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "alias_idx": {
+ "name": "alias_idx",
+ "columns": [
+ "alias"
+ ],
+ "isUnique": false
+ },
+ "space_idx": {
+ "name": "space_idx",
+ "columns": [
+ "spaceId"
+ ],
+ "isUnique": false
+ },
+ "file_idx": {
+ "name": "file_idx",
+ "columns": [
+ "fileId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "spaces_roots_spaceId_spaces_id_fk": {
+ "name": "spaces_roots_spaceId_spaces_id_fk",
+ "tableFrom": "spaces_roots",
+ "tableTo": "spaces",
+ "columnsFrom": [
+ "spaceId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "spaces_roots_fileId_files_id_fk": {
+ "name": "spaces_roots_fileId_files_id_fk",
+ "tableFrom": "spaces_roots",
+ "tableTo": "files",
+ "columnsFrom": [
+ "fileId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "spaces_roots_id": {
+ "name": "spaces_roots_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {
+ "space_root_alias_uniq": {
+ "name": "space_root_alias_uniq",
+ "columns": [
+ "id",
+ "alias"
+ ]
+ }
+ },
+ "checkConstraint": {}
+ },
+ "shares": {
+ "name": "shares",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "ownerId": {
+ "name": "ownerId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "parentId": {
+ "name": "parentId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "spaceId": {
+ "name": "spaceId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "spaceRootId": {
+ "name": "spaceRootId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "fileId": {
+ "name": "fileId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "externalPath": {
+ "name": "externalPath",
+ "type": "varchar(4096)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "tinyint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "alias": {
+ "name": "alias",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "description": {
+ "name": "description",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "storageUsage": {
+ "name": "storageUsage",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "storageQuota": {
+ "name": "storageQuota",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "storageIndexing": {
+ "name": "storageIndexing",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
+ },
+ "disabledAt": {
+ "name": "disabledAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "alias_idx": {
+ "name": "alias_idx",
+ "columns": [
+ "alias"
+ ],
+ "isUnique": true
+ },
+ "parent_idx": {
+ "name": "parent_idx",
+ "columns": [
+ "parentId"
+ ],
+ "isUnique": false
+ },
+ "owner_idx": {
+ "name": "owner_idx",
+ "columns": [
+ "ownerId"
+ ],
+ "isUnique": false
+ },
+ "space_idx": {
+ "name": "space_idx",
+ "columns": [
+ "spaceId"
+ ],
+ "isUnique": false
+ },
+ "space_root_idx": {
+ "name": "space_root_idx",
+ "columns": [
+ "spaceRootId"
+ ],
+ "isUnique": false
+ },
+ "file_idx": {
+ "name": "file_idx",
+ "columns": [
+ "fileId"
+ ],
+ "isUnique": false
+ },
+ "type_idx": {
+ "name": "type_idx",
+ "columns": [
+ "type"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "shares_ownerId_users_id_fk": {
+ "name": "shares_ownerId_users_id_fk",
+ "tableFrom": "shares",
+ "tableTo": "users",
+ "columnsFrom": [
+ "ownerId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shares_parentId_shares_id_fk": {
+ "name": "shares_parentId_shares_id_fk",
+ "tableFrom": "shares",
+ "tableTo": "shares",
+ "columnsFrom": [
+ "parentId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shares_spaceId_spaces_id_fk": {
+ "name": "shares_spaceId_spaces_id_fk",
+ "tableFrom": "shares",
+ "tableTo": "spaces",
+ "columnsFrom": [
+ "spaceId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shares_spaceRootId_spaces_roots_id_fk": {
+ "name": "shares_spaceRootId_spaces_roots_id_fk",
+ "tableFrom": "shares",
+ "tableTo": "spaces_roots",
+ "columnsFrom": [
+ "spaceRootId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shares_fileId_files_id_fk": {
+ "name": "shares_fileId_files_id_fk",
+ "tableFrom": "shares",
+ "tableTo": "files",
+ "columnsFrom": [
+ "fileId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "shares_id": {
+ "name": "shares_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "shares_members": {
+ "name": "shares_members",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "shareId": {
+ "name": "shareId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "groupId": {
+ "name": "groupId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "linkId": {
+ "name": "linkId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "varchar(32)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "share_idx": {
+ "name": "share_idx",
+ "columns": [
+ "shareId"
+ ],
+ "isUnique": false
+ },
+ "user_idx": {
+ "name": "user_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "group_idx": {
+ "name": "group_idx",
+ "columns": [
+ "groupId"
+ ],
+ "isUnique": false
+ },
+ "link_idx": {
+ "name": "link_idx",
+ "columns": [
+ "linkId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "shares_members_shareId_shares_id_fk": {
+ "name": "shares_members_shareId_shares_id_fk",
+ "tableFrom": "shares_members",
+ "tableTo": "shares",
+ "columnsFrom": [
+ "shareId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shares_members_userId_users_id_fk": {
+ "name": "shares_members_userId_users_id_fk",
+ "tableFrom": "shares_members",
+ "tableTo": "users",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shares_members_groupId_groups_id_fk": {
+ "name": "shares_members_groupId_groups_id_fk",
+ "tableFrom": "shares_members",
+ "tableTo": "groups",
+ "columnsFrom": [
+ "groupId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shares_members_linkId_links_id_fk": {
+ "name": "shares_members_linkId_links_id_fk",
+ "tableFrom": "shares_members",
+ "tableTo": "links",
+ "columnsFrom": [
+ "linkId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "shares_members_id": {
+ "name": "shares_members_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {
+ "share_user_uniq": {
+ "name": "share_user_uniq",
+ "columns": [
+ "shareId",
+ "userId"
+ ]
+ },
+ "share_group_uniq": {
+ "name": "share_group_uniq",
+ "columns": [
+ "shareId",
+ "groupId"
+ ]
+ },
+ "share_link_uniq": {
+ "name": "share_link_uniq",
+ "columns": [
+ "shareId",
+ "linkId"
+ ]
+ }
+ },
+ "checkConstraint": {}
+ },
+ "files": {
+ "name": "files",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "ownerId": {
+ "name": "ownerId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "spaceId": {
+ "name": "spaceId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "spaceExternalRootId": {
+ "name": "spaceExternalRootId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "shareExternalId": {
+ "name": "shareExternalId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "path": {
+ "name": "path",
+ "type": "varchar(4096)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "isDir": {
+ "name": "isDir",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "inTrash": {
+ "name": "inTrash",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "mime": {
+ "name": "mime",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "size": {
+ "name": "size",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 0
+ },
+ "mtime": {
+ "name": "mtime",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 0
+ },
+ "ctime": {
+ "name": "ctime",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 0
+ }
+ },
+ "indexes": {
+ "owner_idx": {
+ "name": "owner_idx",
+ "columns": [
+ "ownerId"
+ ],
+ "isUnique": false
+ },
+ "space_idx": {
+ "name": "space_idx",
+ "columns": [
+ "spaceId"
+ ],
+ "isUnique": false
+ },
+ "space_external_root_idx": {
+ "name": "space_external_root_idx",
+ "columns": [
+ "spaceExternalRootId"
+ ],
+ "isUnique": false
+ },
+ "share_external_idx": {
+ "name": "share_external_idx",
+ "columns": [
+ "shareExternalId"
+ ],
+ "isUnique": false
+ },
+ "name_idx": {
+ "name": "name_idx",
+ "columns": [
+ "name"
+ ],
+ "isUnique": false
+ },
+ "path_idx": {
+ "name": "path_idx",
+ "columns": [
+ "path"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "files_ownerId_users_id_fk": {
+ "name": "files_ownerId_users_id_fk",
+ "tableFrom": "files",
+ "tableTo": "users",
+ "columnsFrom": [
+ "ownerId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "files_spaceId_spaces_id_fk": {
+ "name": "files_spaceId_spaces_id_fk",
+ "tableFrom": "files",
+ "tableTo": "spaces",
+ "columnsFrom": [
+ "spaceId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "files_spaceExternalRootId_spaces_roots_id_fk": {
+ "name": "files_spaceExternalRootId_spaces_roots_id_fk",
+ "tableFrom": "files",
+ "tableTo": "spaces_roots",
+ "columnsFrom": [
+ "spaceExternalRootId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "files_shareExternalId_shares_id_fk": {
+ "name": "files_shareExternalId_shares_id_fk",
+ "tableFrom": "files",
+ "tableTo": "shares",
+ "columnsFrom": [
+ "shareExternalId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "files_id": {
+ "name": "files_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "files_recents": {
+ "name": "files_recents",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ownerId": {
+ "name": "ownerId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "spaceId": {
+ "name": "spaceId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "shareId": {
+ "name": "shareId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "path": {
+ "name": "path",
+ "type": "varchar(4096)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "mime": {
+ "name": "mime",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "mtime": {
+ "name": "mtime",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "owner_idx": {
+ "name": "owner_idx",
+ "columns": [
+ "ownerId"
+ ],
+ "isUnique": false
+ },
+ "space_idx": {
+ "name": "space_idx",
+ "columns": [
+ "spaceId"
+ ],
+ "isUnique": false
+ },
+ "share_idx": {
+ "name": "share_idx",
+ "columns": [
+ "shareId"
+ ],
+ "isUnique": false
+ },
+ "mtime_idx": {
+ "name": "mtime_idx",
+ "columns": [
+ "mtime"
+ ],
+ "isUnique": false
+ },
+ "path_idx": {
+ "name": "path_idx",
+ "columns": [
+ "path"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "files_recents_ownerId_users_id_fk": {
+ "name": "files_recents_ownerId_users_id_fk",
+ "tableFrom": "files_recents",
+ "tableTo": "users",
+ "columnsFrom": [
+ "ownerId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "files_recents_spaceId_spaces_id_fk": {
+ "name": "files_recents_spaceId_spaces_id_fk",
+ "tableFrom": "files_recents",
+ "tableTo": "spaces",
+ "columnsFrom": [
+ "spaceId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "files_recents_shareId_shares_id_fk": {
+ "name": "files_recents_shareId_shares_id_fk",
+ "tableFrom": "files_recents",
+ "tableTo": "shares",
+ "columnsFrom": [
+ "shareId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "links": {
+ "name": "links",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "uuid": {
+ "name": "uuid",
+ "type": "varchar(32)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "email": {
+ "name": "email",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "requireAuth": {
+ "name": "requireAuth",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "nbAccess": {
+ "name": "nbAccess",
+ "type": "int unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "limitAccess": {
+ "name": "limitAccess",
+ "type": "int unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "expiresAt": {
+ "name": "expiresAt",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "user_idx": {
+ "name": "user_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "uuid_idx": {
+ "name": "uuid_idx",
+ "columns": [
+ "uuid"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "links_userId_users_id_fk": {
+ "name": "links_userId_users_id_fk",
+ "tableFrom": "links",
+ "tableTo": "users",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "links_id": {
+ "name": "links_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "comments": {
+ "name": "comments",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "userId": {
+ "name": "userId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "fileId": {
+ "name": "fileId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "modifiedAt": {
+ "name": "modifiedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "user_idx": {
+ "name": "user_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "file_idx": {
+ "name": "file_idx",
+ "columns": [
+ "fileId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "comments_userId_users_id_fk": {
+ "name": "comments_userId_users_id_fk",
+ "tableFrom": "comments",
+ "tableTo": "users",
+ "columnsFrom": [
+ "userId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "comments_fileId_files_id_fk": {
+ "name": "comments_fileId_files_id_fk",
+ "tableFrom": "comments",
+ "tableTo": "files",
+ "columnsFrom": [
+ "fileId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "comments_id": {
+ "name": "comments_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "notifications": {
+ "name": "notifications",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "fromUserId": {
+ "name": "fromUserId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "toUserId": {
+ "name": "toUserId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "content": {
+ "name": "content",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "wasRead": {
+ "name": "wasRead",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "from_user_idx": {
+ "name": "from_user_idx",
+ "columns": [
+ "fromUserId"
+ ],
+ "isUnique": false
+ },
+ "to_user_idx": {
+ "name": "to_user_idx",
+ "columns": [
+ "toUserId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "notifications_fromUserId_users_id_fk": {
+ "name": "notifications_fromUserId_users_id_fk",
+ "tableFrom": "notifications",
+ "tableTo": "users",
+ "columnsFrom": [
+ "fromUserId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "notifications_toUserId_users_id_fk": {
+ "name": "notifications_toUserId_users_id_fk",
+ "tableFrom": "notifications",
+ "tableTo": "users",
+ "columnsFrom": [
+ "toUserId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "notifications_id": {
+ "name": "notifications_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "sync_clients": {
+ "name": "sync_clients",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "char(36)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ownerId": {
+ "name": "ownerId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "token": {
+ "name": "token",
+ "type": "char(36)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "tokenExpiration": {
+ "name": "tokenExpiration",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "info": {
+ "name": "info",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "currentIp": {
+ "name": "currentIp",
+ "type": "varchar(45)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "lastIp": {
+ "name": "lastIp",
+ "type": "varchar(45)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "currentAccess": {
+ "name": "currentAccess",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "lastAccess": {
+ "name": "lastAccess",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "owner_idx": {
+ "name": "owner_idx",
+ "columns": [
+ "ownerId"
+ ],
+ "isUnique": false
+ },
+ "token_idx": {
+ "name": "token_idx",
+ "columns": [
+ "token"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "sync_clients_ownerId_users_id_fk": {
+ "name": "sync_clients_ownerId_users_id_fk",
+ "tableFrom": "sync_clients",
+ "tableTo": "users",
+ "columnsFrom": [
+ "ownerId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "sync_clients_id": {
+ "name": "sync_clients_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "sync_paths": {
+ "name": "sync_paths",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "clientId": {
+ "name": "clientId",
+ "type": "char(36)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ownerId": {
+ "name": "ownerId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "spaceId": {
+ "name": "spaceId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "spaceRootId": {
+ "name": "spaceRootId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "shareId": {
+ "name": "shareId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "fileId": {
+ "name": "fileId",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "settings": {
+ "name": "settings",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "client_idx": {
+ "name": "client_idx",
+ "columns": [
+ "clientId"
+ ],
+ "isUnique": false
+ },
+ "owner_idx": {
+ "name": "owner_idx",
+ "columns": [
+ "ownerId"
+ ],
+ "isUnique": false
+ },
+ "space_idx": {
+ "name": "space_idx",
+ "columns": [
+ "spaceId"
+ ],
+ "isUnique": false
+ },
+ "space_root_idx": {
+ "name": "space_root_idx",
+ "columns": [
+ "spaceRootId"
+ ],
+ "isUnique": false
+ },
+ "share_idx": {
+ "name": "share_idx",
+ "columns": [
+ "shareId"
+ ],
+ "isUnique": false
+ },
+ "file_idx": {
+ "name": "file_idx",
+ "columns": [
+ "fileId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "sync_paths_clientId_sync_clients_id_fk": {
+ "name": "sync_paths_clientId_sync_clients_id_fk",
+ "tableFrom": "sync_paths",
+ "tableTo": "sync_clients",
+ "columnsFrom": [
+ "clientId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sync_paths_ownerId_users_id_fk": {
+ "name": "sync_paths_ownerId_users_id_fk",
+ "tableFrom": "sync_paths",
+ "tableTo": "users",
+ "columnsFrom": [
+ "ownerId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sync_paths_spaceId_spaces_id_fk": {
+ "name": "sync_paths_spaceId_spaces_id_fk",
+ "tableFrom": "sync_paths",
+ "tableTo": "spaces",
+ "columnsFrom": [
+ "spaceId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sync_paths_spaceRootId_spaces_roots_id_fk": {
+ "name": "sync_paths_spaceRootId_spaces_roots_id_fk",
+ "tableFrom": "sync_paths",
+ "tableTo": "spaces_roots",
+ "columnsFrom": [
+ "spaceRootId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sync_paths_shareId_shares_id_fk": {
+ "name": "sync_paths_shareId_shares_id_fk",
+ "tableFrom": "sync_paths",
+ "tableTo": "shares",
+ "columnsFrom": [
+ "shareId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sync_paths_fileId_files_id_fk": {
+ "name": "sync_paths_fileId_files_id_fk",
+ "tableFrom": "sync_paths",
+ "tableTo": "files",
+ "columnsFrom": [
+ "fileId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "sync_paths_id": {
+ "name": "sync_paths_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ }
+ },
+ "views": {},
+ "_meta": {
+ "schemas": {},
+ "tables": {},
+ "columns": {}
+ },
+ "internal": {
+ "tables": {},
+ "indexes": {}
+ }
+}
\ No newline at end of file
diff --git a/backend/migrations/meta/_journal.json b/backend/migrations/meta/_journal.json
index c95ad1c6..b733c2d6 100644
--- a/backend/migrations/meta/_journal.json
+++ b/backend/migrations/meta/_journal.json
@@ -29,6 +29,13 @@
"when": 1760089921667,
"tag": "0003_fancy_gauntlet",
"breakpoints": true
+ },
+ {
+ "idx": 4,
+ "version": "5",
+ "when": 1760345527424,
+ "tag": "0004_soft_sphinx",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/backend/src/applications/files/services/files-manager.service.ts b/backend/src/applications/files/services/files-manager.service.ts
index cb7ae012..ea4aa304 100644
--- a/backend/src/applications/files/services/files-manager.service.ts
+++ b/backend/src/applications/files/services/files-manager.service.ts
@@ -333,8 +333,8 @@ export class FilesManager {
if (!isMove || (isMove && srcSpace.id !== dstSpace.id)) {
const size = isDir ? (await dirSize(srcSpace.realPath))[0] : await fileSize(srcSpace.realPath)
if (dstSpace.willExceedQuota(size)) {
- this.logger.warn(`${this.copyMove.name} - quota will be exceeded for *${dstSpace.alias}* (${dstSpace.id})`)
- throw new FileError(HttpStatus.INSUFFICIENT_STORAGE, 'Quota will be exceeded')
+ this.logger.warn(`${this.copyMove.name} - storage quota will be exceeded for *${dstSpace.alias}* (${dstSpace.id})`)
+ throw new FileError(HttpStatus.INSUFFICIENT_STORAGE, 'Storage quota will be exceeded')
}
}
}
diff --git a/backend/src/applications/files/services/files-parser.service.ts b/backend/src/applications/files/services/files-parser.service.ts
index e99998da..a6c08679 100644
--- a/backend/src/applications/files/services/files-parser.service.ts
+++ b/backend/src/applications/files/services/files-parser.service.ts
@@ -42,7 +42,7 @@ export class FilesParser {
login: users.login
})
.from(users)
- .where(and(...[lte(users.role, USER_ROLE.USER), eq(users.storageIndexing, true), ...(userId ? [eq(users.id, userId)] : [])]))) {
+ .where(and(...[eq(users.storageIndexing, true), lte(users.role, USER_ROLE.USER), ...(userId ? [eq(users.id, userId)] : [])]))) {
const userFilesPath = UserModel.getFilesPath(user.login)
if (!(await isPathExists(userFilesPath))) {
this.logger.warn(`${this.userPaths.name} - user path does not exist : ${userFilesPath}`)
@@ -118,7 +118,7 @@ export class FilesParser {
)
.leftJoin(spaces, and(isNull(shares.externalPath), isNotNull(files.spaceId), eq(spaces.id, files.spaceId), eq(spaces.storageIndexing, true)))
.leftJoin(users, and(eq(users.id, files.ownerId), eq(users.storageIndexing, true)))
- .where(and(...[eq(shares.type, SHARE_TYPE.COMMON), ...(shareIds ? [inArray(shares.id, shareIds)] : [])]))
+ .where(and(eq(shares.storageIndexing, true), ...[eq(shares.type, SHARE_TYPE.COMMON), ...(shareIds ? [inArray(shares.id, shareIds)] : [])]))
.groupBy(shares.id)) {
let shareFilesPath: string
if (share.externalPath) {
diff --git a/backend/src/applications/files/services/files-scheduler.service.ts b/backend/src/applications/files/services/files-scheduler.service.ts
index 900e2f81..d67ddc64 100644
--- a/backend/src/applications/files/services/files-scheduler.service.ts
+++ b/backend/src/applications/files/services/files-scheduler.service.ts
@@ -66,7 +66,6 @@ export class FilesScheduler {
.from(users)) {
const userTasksPath = UserModel.getTasksPath(user.login, user.role === USER_ROLE.GUEST, user.role === USER_ROLE.LINK)
if (!(await isPathExists(userTasksPath))) {
- this.logger.verbose(`${this.cleanupUserTaskFiles.name} - *${user.login}* tasks path does not exist`)
continue
}
if (await dirHasChildren(userTasksPath, false)) {
@@ -91,7 +90,7 @@ export class FilesScheduler {
}
@Timeout(30000)
- @Cron(CronExpression.EVERY_DAY_AT_MIDNIGHT)
+ @Cron(CronExpression.EVERY_8_HOURS)
async clearRecentFiles(): Promise<void> {
this.logger.log(`${this.clearRecentFiles.name} - START`)
const keepNumber = 100
diff --git a/backend/src/applications/shares/dto/create-or-update-share.dto.ts b/backend/src/applications/shares/dto/create-or-update-share.dto.ts
index db107302..5914a24d 100644
--- a/backend/src/applications/shares/dto/create-or-update-share.dto.ts
+++ b/backend/src/applications/shares/dto/create-or-update-share.dto.ts
@@ -127,6 +127,14 @@ export class CreateOrUpdateShareDto {
@IsBoolean()
enabled?: boolean
+ @IsOptional()
+ @IsInt()
+ storageQuota?: number = null
+
+ @IsOptional()
+ @IsBoolean()
+ storageIndexing?: boolean
+
@IsOptional()
@ValidateNested()
@Type(() => ShareParentDto)
diff --git a/backend/src/applications/shares/interfaces/share-props.interface.ts b/backend/src/applications/shares/interfaces/share-props.interface.ts
index b1bdde36..ae16b67a 100644
--- a/backend/src/applications/shares/interfaces/share-props.interface.ts
+++ b/backend/src/applications/shares/interfaces/share-props.interface.ts
@@ -8,7 +8,23 @@ import type { Member } from '../../users/interfaces/member.interface'
import type { Share } from '../schemas/share.interface'
export class ShareProps
- implements Pick<Share, 'id' | 'ownerId' | 'name' | 'alias' | 'enabled' | 'description' | 'externalPath' | 'createdAt' | 'modifiedAt' | 'disabledAt'>
+ implements
+ Pick<
+ Share,
+ | 'id'
+ | 'ownerId'
+ | 'name'
+ | 'alias'
+ | 'enabled'
+ | 'description'
+ | 'externalPath'
+ | 'createdAt'
+ | 'modifiedAt'
+ | 'disabledAt'
+ | 'storageUsage'
+ | 'storageQuota'
+ | 'storageIndexing'
+ >
{
id: number
ownerId: number
@@ -17,6 +33,9 @@ export class ShareProps
description: string
enabled: boolean
externalPath: string
+ storageUsage: number
+ storageQuota: number
+ storageIndexing: boolean
createdAt: Date
modifiedAt: Date
disabledAt: Date
diff --git a/backend/src/applications/shares/schemas/share.interface.ts b/backend/src/applications/shares/schemas/share.interface.ts
index 86f65809..7b94d3e9 100644
--- a/backend/src/applications/shares/schemas/share.interface.ts
+++ b/backend/src/applications/shares/schemas/share.interface.ts
@@ -21,6 +21,9 @@ export class Share implements ShareSchema {
name: string
enabled: boolean
description: string
+ storageUsage: number
+ storageQuota: number
+ storageIndexing: boolean
createdAt: Date
modifiedAt: Date
disabledAt: Date
diff --git a/backend/src/applications/shares/schemas/shares.schema.ts b/backend/src/applications/shares/schemas/shares.schema.ts
index 3a7e749d..c4ded410 100644
--- a/backend/src/applications/shares/schemas/shares.schema.ts
+++ b/backend/src/applications/shares/schemas/shares.schema.ts
@@ -32,12 +32,19 @@ import { users } from '../../users/schemas/users.schema'
alias: used to navigate over web & webdav, must be unique
name: set by user and showed to others
- parent: if the share is a child share :
+ parent: if the share is a child share:
- parentId is required
- spaceId & spaceRootId must have the same value as their parents
- fileId is required when the file is inside the parent share
- fileId is not required when child share is directly linked to parent share (with a space root or an external path)
- - if the share has an external path : file.shareExternalId must match with the first parent share
+ - if the share has an external path: file.shareExternalId must match with the first parent share
+
+ storageQuota:
+ 0 : no storage
+ null : unlimited
+ other: limited to value
+
+ Storage properties are only used for shares that have an external path.
*/
export const shares = mysqlTable(
@@ -55,6 +62,9 @@ export const shares = mysqlTable(
name: varchar('name', { length: 255 }).notNull(),
enabled: boolean('enabled').default(true).notNull(),
description: varchar('description', { length: 255 }),
+ storageUsage: bigint('storageUsage', { mode: 'number', unsigned: true }).default(0).notNull(),
+ storageQuota: bigint('storageQuota', { mode: 'number', unsigned: true }),
+ storageIndexing: boolean('storageIndexing').default(true).notNull(),
createdAt: datetime('createdAt', { mode: 'date' })
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
diff --git a/backend/src/applications/shares/services/shares-manager.service.ts b/backend/src/applications/shares/services/shares-manager.service.ts
index de57b61b..280a52c6 100644
--- a/backend/src/applications/shares/services/shares-manager.service.ts
+++ b/backend/src/applications/shares/services/shares-manager.service.ts
@@ -16,11 +16,11 @@ import {
hashPassword,
intersectPermissions
} from '../../../common/functions'
-import type { Entries } from '../../../common/interfaces'
+import type { Entries, StorageQuota } from '../../../common/interfaces'
import { ContextManager } from '../../../infrastructure/context/services/context-manager.service'
import type { FileProps } from '../../files/interfaces/file-props.interface'
import { FileError } from '../../files/models/file-error'
-import { checkExternalPath, getProps, isPathExists } from '../../files/utils/files'
+import { checkExternalPath, dirSize, getProps, isPathExists } from '../../files/utils/files'
import { LINK_TYPE } from '../../links/constants/links'
import type { CreateOrUpdateLinkDto } from '../../links/dto/create-or-update-link.dto'
import type { LinkGuest } from '../../links/interfaces/link-guest.interface'
@@ -30,6 +30,7 @@ import { NOTIFICATION_APP, NOTIFICATION_APP_EVENT } from '../../notifications/co
import type { NotificationContent, NotificationOptions } from '../../notifications/interfaces/notification-properties.interface'
import type { UserMailNotification } from '../../notifications/interfaces/user-mail-notification'
import { NotificationsManager } from '../../notifications/services/notifications-manager.service'
+import { CACHE_QUOTA_SHARE_PREFIX, CACHE_QUOTA_TTL } from '../../spaces/constants/cache'
import { SPACE_OPERATION, SPACE_PERMS_SEP, SPACE_REPOSITORY, SPACE_ROLE } from '../../spaces/constants/spaces'
import type { SpaceMemberDto } from '../../spaces/dto/create-or-update-space.dto'
import { SpaceEnv } from '../../spaces/models/space-env.model'
@@ -62,7 +63,7 @@ export class SharesManager {
private readonly contextManager: ContextManager,
private readonly notificationsManager: NotificationsManager,
private readonly sharesQueries: SharesQueries,
- private readonly spaceQueries: SpacesQueries,
+ private readonly spacesQueries: SpacesQueries,
private readonly usersQueries: UsersQueries,
private readonly linksQueries: LinksQueries
) {}
@@ -90,7 +91,7 @@ export class SharesManager {
} else if (share.file?.space?.alias) {
share.file.ownerId = null
// retrieve space permissions (cached query)
- const spacePermissions: Partial<SpaceEnv> = await this.spaceQueries.permissions(user.id, share.file.space.alias, share.file.space.root?.alias)
+ const spacePermissions: Partial<SpaceEnv> = await this.spacesQueries.permissions(user.id, share.file.space.alias, share.file.space.root?.alias)
if (!spacePermissions) {
this.logger.warn(`${this.setAllowedPermissions.name} - missing space permissions : ${JSON.stringify(share)}`)
throw new HttpException('Space not found', HttpStatus.NOT_FOUND)
@@ -132,6 +133,8 @@ export class SharesManager {
description: createOrUpdateShareDto.description,
externalPath: createOrUpdateShareDto.externalPath,
enabled: createOrUpdateShareDto.enabled,
+ storageQuota: createOrUpdateShareDto.storageQuota,
+ storageIndexing: createOrUpdateShareDto.storageIndexing,
disabledAt: createOrUpdateShareDto.enabled ? null : new Date(),
type: createOrUpdateShareDto.type || SHARE_TYPE.COMMON
}
@@ -159,10 +162,10 @@ export class SharesManager {
throw new HttpException('The location does not exist', HttpStatus.NOT_FOUND)
}
const fileProps: FileProps = { ...(await getProps(realPath, createOrUpdateShareDto.file.path)), id: createOrUpdateShareDto.file.id }
- share.fileId = await this.spaceQueries.getOrCreateUserFile(user.id, fileProps)
+ share.fileId = await this.spacesQueries.getOrCreateUserFile(user.id, fileProps)
} else if (createOrUpdateShareDto.file.space?.alias) {
/* SPACE CASE */
- const spacePermissions: Partial<SpaceEnv> = await this.spaceQueries.permissions(
+ const spacePermissions: Partial<SpaceEnv> = await this.spacesQueries.permissions(
user.id,
createOrUpdateShareDto.file.space.alias,
createOrUpdateShareDto.file.space.root.alias
@@ -207,7 +210,7 @@ export class SharesManager {
if (!isSpaceRoot && !isExternalSpaceRoot) {
const fileProps: FileProps = { ...(await getProps(space.realPath, space.dbFile.path)), id: undefined }
// get or create file id
- share.fileId = await this.spaceQueries.getOrCreateSpaceFile(createOrUpdateShareDto.file.id, fileProps, space.dbFile)
+ share.fileId = await this.spacesQueries.getOrCreateSpaceFile(createOrUpdateShareDto.file.id, fileProps, space.dbFile)
}
} else {
// unexpected case
@@ -223,11 +226,12 @@ export class SharesManager {
}
async updateShare(user: UserModel, shareId: number, createOrUpdateShareDto: CreateOrUpdateShareDto, asAdmin = false): Promise<ShareProps> {
- // asAdmin : true if the user is the owner of the parent share or if the share is requested from the administration
+ // asAdmin: true if the user is the owner of the parent share or if the share is requested from the administration
const share: ShareProps = await this.getShareWithMembers(user, shareId, asAdmin)
- // check & update share info
+ // check and update share info
const shareDiffProps: Partial<ShareProps> = { modifiedAt: new Date() }
- for (const prop of ['name', 'description', 'enabled']) {
+ const props: (keyof CreateOrUpdateShareDto)[] = ['name', 'description', 'enabled', 'storageQuota', 'storageIndexing']
+ for (const prop of props) {
if (createOrUpdateShareDto[prop] !== share[prop]) {
shareDiffProps[prop] = createOrUpdateShareDto[prop]
if (prop === 'name') {
@@ -238,7 +242,9 @@ export class SharesManager {
}
}
// update in db
- this.sharesQueries.updateShare(shareDiffProps, { id: shareId }).catch((e: Error) => this.logger.error(`${this.updateShare.name} - ${e}`))
+ if (!(await this.sharesQueries.updateShare(shareId, shareDiffProps))) {
+ throw new HttpException('Unable to update share', HttpStatus.INTERNAL_SERVER_ERROR)
+ }
// check & update members
const linkMembers: ShareMemberDto[] = await this.createOrUpdateLinksAsMembers(user, share, LINK_TYPE.SHARE, createOrUpdateShareDto.links)
// intersect share permissions for members
@@ -354,7 +360,7 @@ export class SharesManager {
if (!isLinkedToShareSpaceRoot && !isLinkedToShareExternalPath) {
// fileId is mandatory for a file in a child share
const fileProps: FileProps = { ...(await getProps(pShareEnv.realPath, pShareEnv.dbFile.path)), id: undefined }
- fileId = await this.spaceQueries.getOrCreateSpaceFile(createOrUpdateShareDto.file.id, fileProps, pShareEnv.dbFile)
+ fileId = await this.spacesQueries.getOrCreateSpaceFile(createOrUpdateShareDto.file.id, fileProps, pShareEnv.dbFile)
}
const share: Partial<Share> = {
@@ -709,6 +715,29 @@ export class SharesManager {
await this.deleteGuestLinks(members)
}
+ async updateSharesExternalPathQuota(shareId?: number) {
+ for (const share of await this.sharesQueries.sharesQuotaExternalPaths(shareId)) {
+ if (!(await isPathExists(share.externalPath))) {
+ this.logger.warn(`${this.updateSharesExternalPathQuota.name} - *${share.alias}* home path does not exist`)
+ continue
+ }
+ const [size, errors] = await dirSize(share.externalPath)
+ for (const [path, error] of Object.entries(errors)) {
+ this.logger.warn(`${this.updateSharesExternalPathQuota.name} - unable to get size for *${share.alias}* on ${path} : ${error}`)
+ }
+ const shareQuota: StorageQuota = { storageUsage: size, storageQuota: share.storageQuota }
+ this.sharesQueries.cache
+ .set(`${CACHE_QUOTA_SHARE_PREFIX}-${share.id}`, shareQuota, CACHE_QUOTA_TTL)
+ .catch((e: Error) => this.logger.error(`${this.updateSharesExternalPathQuota.name} - ${e}`))
+ if (share.storageUsage !== shareQuota.storageUsage) {
+ this.logger.log(
+ `${this.updateSharesExternalPathQuota.name} - share *${share.alias}* (${share.id}) : storage usage updated : ${shareQuota.storageUsage}`
+ )
+ await this.sharesQueries.updateShare(share.id, { storageUsage: shareQuota.storageUsage })
+ }
+ }
+ }
+
private async updateMembers(user: UserModel, share: Partial<Share>, oldMembers: ShareMemberDto[], currentMembers: ShareMemberDto[]) {
if (oldMembers.length === 0 && currentMembers.length === 0) {
return
@@ -947,8 +976,8 @@ export class SharesManager {
const members: ShareChildMember[] = await this.sharesQueries.membersFromChildSharesPermissions(share.id, [share.ownerId], null, false)
await this.sharesQueries.deleteShare(share.id)
this.logger.log(`${this.removeShareFromOwners.name} - share *${share.alias}* (${share.id}) from owner (${share.ownerId}) was removed`)
- // clear cache & notify users
- if (!fromUserId || fromUserId !== share.ownerId) {
+ // clear cache and notify users
+ if (share.ownerId && (!fromUserId || fromUserId !== share.ownerId)) {
this.clearCachePermissionsAndOrNotify(share, ACTION.DELETE_PERMANENTLY, [share.ownerId]).catch((e: Error) =>
this.logger.error(`${this.removeShareFromOwners.name} - ${e}`)
)
diff --git a/backend/src/applications/shares/services/shares-queries.service.ts b/backend/src/applications/shares/services/shares-queries.service.ts
index 06321518..a09aaed3 100644
--- a/backend/src/applications/shares/services/shares-queries.service.ts
+++ b/backend/src/applications/shares/services/shares-queries.service.ts
@@ -65,7 +65,7 @@ export class SharesQueries {
constructor(
@Inject(DB_TOKEN_PROVIDER) private readonly db: DBSchema,
- private readonly cache: Cache
+ public readonly cache: Cache
) {}
async uniqueShareAlias(name: string): Promise<string> {
@@ -147,6 +147,19 @@ export class SharesQueries {
.where(and(...where))
}
+ sharesQuotaExternalPaths(shareId?: number): Promise<Partial<Share>[]> {
+ return this.db
+ .select({
+ id: shares.id,
+ alias: shares.alias,
+ storageUsage: shares.storageUsage,
+ storageQuota: shares.storageQuota,
+ externalPath: shares.externalPath
+ })
+ .from(shares)
+ .where(and(isNotNull(shares.externalPath), ...[...(shareId ? [eq(shares.id, shareId)] : [])]))
+ }
+
async listShareLinks(user: UserModel, shareId: number, asAdmin?: boolean): Promise<ShareLink>
async listShareLinks(user: UserModel, shareId?: number, asAdmin?: boolean): Promise<ShareLink[]>
@@ -228,6 +241,9 @@ export class SharesQueries {
externalPath: sql`IF (${shares.externalPath} IS NOT NULL AND ${shares.ownerId} IS NOT NULL, '.', ${shares.externalPath})`,
enabled: shares.enabled,
description: shares.description,
+ storageUsage: shares.storageUsage,
+ storageQuota: shares.storageQuota,
+ storageIndexing: shares.storageIndexing,
createdAt: shares.createdAt,
modifiedAt: shares.modifiedAt,
disabledAt: shares.disabledAt,
@@ -296,20 +312,14 @@ export class SharesQueries {
return dbGetInsertedId(await this.db.insert(shares).values(share as Share))
}
- async updateShare(set: Partial<Record<keyof Share, any>>, filters: Partial<Record<keyof Share, any>>) {
- const where: SQL[] = convertToWhere(shares, filters)
+ async updateShare(id: number, set: Partial<Record<keyof Share, any>>): Promise<boolean> {
try {
- dbCheckAffectedRows(
- await this.db
- .update(shares)
- .set(set)
- .where(and(...where))
- .limit(1),
- 1
- )
- this.logger.debug(`${this.updateShare.name} - ${JSON.stringify(filters)} was updated : ${JSON.stringify(set)}`)
+ dbCheckAffectedRows(await this.db.update(shares).set(set).where(eq(shares.id, id)).limit(1), 1)
+ this.logger.debug(`${this.updateShare.name} - share (${id}) was updated : ${JSON.stringify(set)}`)
+ return true
} catch (e) {
- this.logger.error(`${this.updateShare.name} - ${JSON.stringify(filters)} was not updated : ${JSON.stringify(set)} : ${e}`)
+ this.logger.error(`${this.updateShare.name} - share (${id}) was not updated : ${JSON.stringify(set)} : ${e}`)
+ return false
}
}
diff --git a/backend/src/applications/spaces/constants/cache.ts b/backend/src/applications/spaces/constants/cache.ts
index 617bf123..02eaf6c3 100644
--- a/backend/src/applications/spaces/constants/cache.ts
+++ b/backend/src/applications/spaces/constants/cache.ts
@@ -7,4 +7,5 @@
// cache quota key = `(quota-user|quota-space)-${id}` => number
export const CACHE_QUOTA_USER_PREFIX = 'quota-user'
export const CACHE_QUOTA_SPACE_PREFIX = 'quota-space'
+export const CACHE_QUOTA_SHARE_PREFIX = 'quota-share'
export const CACHE_QUOTA_TTL = 86400 // 1 day
diff --git a/backend/src/applications/spaces/guards/space.guard.ts b/backend/src/applications/spaces/guards/space.guard.ts
index fcc6f6eb..30cc03cf 100644
--- a/backend/src/applications/spaces/guards/space.guard.ts
+++ b/backend/src/applications/spaces/guards/space.guard.ts
@@ -45,12 +45,12 @@ export class SpaceGuard implements CanActivate {
}
if ([SPACE_OPERATION.ADD, SPACE_OPERATION.MODIFY].indexOf(permission) > -1) {
if (req.space.quotaIsExceeded) {
- logger.warn(`Space quota is exceeded for *${req.space.alias}* (${req.space.id})`)
- throw new HttpException('Space quota is exceeded', HttpStatus.INSUFFICIENT_STORAGE)
+ logger.warn(`Storage quota exceeded for *${req.space.alias}* (${req.space.id})`)
+ throw new HttpException('Storage quota exceeded', HttpStatus.INSUFFICIENT_STORAGE)
} else if (req.space.storageQuota) {
const contentLength = parseInt(req.headers['content-length'] || '0', 10) || 0
if (req.space.willExceedQuota(contentLength)) {
- throw new HttpException('Quota will be exceeded', HttpStatus.INSUFFICIENT_STORAGE)
+ throw new HttpException('Storage quota will be exceeded', HttpStatus.INSUFFICIENT_STORAGE)
}
}
}
diff --git a/backend/src/applications/spaces/interfaces/space-quota.interface.ts b/backend/src/applications/spaces/interfaces/space-quota.interface.ts
deleted file mode 100644
index 0f1960eb..00000000
--- a/backend/src/applications/spaces/interfaces/space-quota.interface.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * Copyright (C) 2012-2025 Johan Legrand <[email protected]>
- * This file is part of Sync-in | The open source file sync and share solution
- * See the LICENSE file for licensing details
- */
-
-export interface SpaceQuota {
- storageUsage: number
- storageQuota: number
-}
diff --git a/backend/src/applications/spaces/services/spaces-manager.service.ts b/backend/src/applications/spaces/services/spaces-manager.service.ts
index 1bfda958..1e5f15d2 100644
--- a/backend/src/applications/spaces/services/spaces-manager.service.ts
+++ b/backend/src/applications/spaces/services/spaces-manager.service.ts
@@ -10,10 +10,9 @@ import fs from 'node:fs/promises'
import path from 'node:path'
import { ACTION } from '../../../common/constants'
import { convertDiffUpdate, diffCollection, differencePermissions } from '../../../common/functions'
-import type { Entries } from '../../../common/interfaces'
+import type { Entries, StorageQuota } from '../../../common/interfaces'
import { createSlug, regExpNumberSuffix } from '../../../common/shared'
import { configuration } from '../../../configuration/config.environment'
-import { Cache } from '../../../infrastructure/cache/services/cache.service'
import { ContextManager } from '../../../infrastructure/context/services/context-manager.service'
import { FileError } from '../../files/models/file-error'
import { dirListFileNames, dirSize, getProps, isPathExists, moveFiles, removeFiles } from '../../files/utils/files'
@@ -29,6 +28,7 @@ import { SharesManager } from '../../shares/services/shares-manager.service'
import { MEMBER_TYPE } from '../../users/constants/member'
import { USER_ROLE } from '../../users/constants/user'
import { UserModel } from '../../users/models/user.model'
+import type { User } from '../../users/schemas/user.interface'
import { users } from '../../users/schemas/users.schema'
import { UsersQueries } from '../../users/services/users-queries.service'
import { CACHE_QUOTA_SPACE_PREFIX, CACHE_QUOTA_TTL, CACHE_QUOTA_USER_PREFIX } from '../constants/cache'
@@ -45,7 +45,6 @@ import {
import { CreateOrUpdateSpaceDto, SpaceMemberDto } from '../dto/create-or-update-space.dto'
import { DeleteSpaceDto } from '../dto/delete-space.dto'
import { SearchSpaceDto } from '../dto/search-space.dto'
-import { SpaceQuota } from '../interfaces/space-quota.interface'
import { SpaceTrash } from '../interfaces/space-trash.interface'
import { SpaceEnv } from '../models/space-env.model'
import { SpaceProps } from '../models/space-props.model'
@@ -64,7 +63,6 @@ export class SpacesManager {
constructor(
private readonly contextManager: ContextManager,
- private readonly cache: Cache,
private readonly spacesQueries: SpacesQueries,
private readonly usersQueries: UsersQueries,
private readonly sharesManager: SharesManager,
@@ -368,10 +366,11 @@ export class SpacesManager {
}
async updatePersonalSpacesQuota(forUser?: UserModel) {
- for (const user of await this.usersQueries.selectUsers(
- ['id', 'login', 'storageUsage', 'storageQuota'],
- [lte(users.role, USER_ROLE.USER), ...(forUser ? [eq(users.id, forUser.id)] : [])]
- )) {
+ const props: (keyof User)[] = ['id', 'login', 'storageUsage', 'storageQuota']
+ for (const user of await this.usersQueries.selectUsers(props, [
+ lte(users.role, USER_ROLE.USER),
+ ...(forUser ? [eq(users.id, forUser.id)] : [])
+ ])) {
const userPath = UserModel.getHomePath(user.login)
if (!(await isPathExists(userPath))) {
this.logger.warn(`${this.updatePersonalSpacesQuota.name} - *${user.login}* home path does not exist`)
@@ -381,8 +380,8 @@ export class SpacesManager {
for (const [path, error] of Object.entries(errors)) {
this.logger.warn(`${this.updatePersonalSpacesQuota.name} - unable to get size for *${user.login}* on ${path} : ${error}`)
}
- const spaceQuota: SpaceQuota = { storageUsage: size, storageQuota: user.storageQuota }
- this.cache
+ const spaceQuota: StorageQuota = { storageUsage: size, storageQuota: user.storageQuota }
+ this.spacesQueries.cache
.set(`${CACHE_QUOTA_USER_PREFIX}-${user.id}`, spaceQuota, CACHE_QUOTA_TTL)
.catch((e: Error) => this.logger.error(`${this.updatePersonalSpacesQuota.name} - ${e}`))
if (user.storageUsage !== spaceQuota.storageUsage) {
@@ -395,19 +394,22 @@ export class SpacesManager {
}
async updateSpacesQuota(spaceId?: number) {
- const props: (keyof Space)[] = ['id', 'alias', 'storageUsage', 'storageQuota']
- for (const space of await this.spacesQueries.selectSpaces(props, [...(spaceId ? [eq(spaces.id, spaceId)] : [])])) {
+ for (const space of await this.spacesQueries.spacesQuotaPaths(spaceId)) {
const spacePath = SpaceModel.getHomePath(space.alias)
if (!(await isPathExists(spacePath))) {
this.logger.warn(`${this.updateSpacesQuota.name} - *${space.alias}* home path does not exist`)
continue
}
- const [size, errors] = await dirSize(spacePath)
- for (const [path, error] of Object.entries(errors)) {
- this.logger.warn(`${this.updateSpacesQuota.name} - unable to get size for *${space.alias}* on ${path} : ${error}`)
+ let size = 0
+ for (const rPath of [spacePath, ...space.externalPaths.filter(Boolean)]) {
+ const [rPathSize, errors] = await dirSize(rPath)
+ size += rPathSize
+ for (const [path, error] of Object.entries(errors)) {
+ this.logger.warn(`${this.updateSpacesQuota.name} - unable to get size for *${space.alias}* on ${path} : ${error}`)
+ }
}
- const spaceQuota: SpaceQuota = { storageUsage: size, storageQuota: space.storageQuota }
- this.cache
+ const spaceQuota: StorageQuota = { storageUsage: size, storageQuota: space.storageQuota }
+ this.spacesQueries.cache
.set(`${CACHE_QUOTA_SPACE_PREFIX}-${space.id}`, spaceQuota, CACHE_QUOTA_TTL)
.catch((e: Error) => this.logger.error(`${this.updateSpacesQuota.name} - ${e}`))
if (space.storageUsage !== spaceQuota.storageUsage) {
@@ -419,10 +421,8 @@ export class SpacesManager {
async deleteExpiredSpaces() {
/* Removes spaces that have been disabled for more than 30 days */
- for (const space of (await this.spacesQueries.selectSpaces(
- ['id', 'name', 'alias', 'disabledAt'],
- [eq(spaces.enabled, false), isNotNull(spaces.disabledAt)]
- )) as Pick<Space, 'id' | 'name' | 'alias' | 'disabledAt'>[]) {
+ const props: (keyof Space)[] = ['id', 'name', 'alias', 'disabledAt']
+ for (const space of await this.spacesQueries.selectSpaces(props, [eq(spaces.enabled, false), isNotNull(spaces.disabledAt)])) {
const disabled = new Date(space.disabledAt)
disabled.setDate(disabled.getDate() + SPACE_MAX_DISABLED_DAYS)
if (new Date() > disabled) {
@@ -714,7 +714,9 @@ export class SpacesManager {
}
await this.spacesQueries.deleteSpace(space.id, deleteNow)
if (deleteNow) {
- this.cache.del(`${CACHE_QUOTA_SPACE_PREFIX}-${space.id}`).catch((e: Error) => this.logger.error(`${this.deleteOrDisableSpace.name} - ${e}`))
+ this.spacesQueries.cache
+ .del(`${CACHE_QUOTA_SPACE_PREFIX}-${space.id}`)
+ .catch((e: Error) => this.logger.error(`${this.deleteOrDisableSpace.name} - ${e}`))
await this.deleteSpaceLocation(space.alias)
}
}
@@ -801,7 +803,7 @@ export class SpacesManager {
private async setQuotaExceeded(user: UserModel, space: SpaceEnv) {
/* extract quota from spaces|shares|roots */
- if (space.inSharesList || (space.inSharesRepository && space.root?.externalPath)) {
+ if (space.inSharesList) {
return
}
const cacheQuotaKey = quotaKeyFromSpace(user.id, space)
@@ -809,15 +811,18 @@ export class SpacesManager {
this.logger.verbose(`${this.setQuotaExceeded.name} - quota was ignored for space : *${space.alias}* (${space.id})`)
return
}
- let quota: SpaceQuota = await this.cache.get(cacheQuotaKey)
+ let quota: StorageQuota = await this.spacesQueries.cache.get(cacheQuotaKey)
if (!quota) {
// the quota scheduler has not started yet or the cache has been cleared
if (space.inPersonalSpace) {
await this.updatePersonalSpacesQuota(user)
+ } else if (space.inSharesRepository) {
+ // Shares with external paths
+ await this.sharesManager.updateSharesExternalPathQuota(space.id)
} else {
await this.updateSpacesQuota(space.id)
}
- quota = await this.cache.get(cacheQuotaKey)
+ quota = await this.spacesQueries.cache.get(cacheQuotaKey)
}
if (quota) {
space.storageUsage = quota.storageUsage
diff --git a/backend/src/applications/spaces/services/spaces-queries.service.ts b/backend/src/applications/spaces/services/spaces-queries.service.ts
index ea806a9f..654102b0 100644
--- a/backend/src/applications/spaces/services/spaces-queries.service.ts
+++ b/backend/src/applications/spaces/services/spaces-queries.service.ts
@@ -29,7 +29,6 @@ import { filePathSQL, files } from '../../files/schemas/files.schema'
import { FilesQueries } from '../../files/services/files-queries.service'
import { links } from '../../links/schemas/links.schema'
import { shares } from '../../shares/schemas/shares.schema'
-import { SharesQueries } from '../../shares/services/shares-queries.service'
import { syncClients } from '../../sync/schemas/sync-clients.schema'
import { syncPaths } from '../../sync/schemas/sync-paths.schema'
import { GROUP_TYPE } from '../../users/constants/group'
@@ -66,9 +65,8 @@ export class SpacesQueries {
constructor(
@Inject(DB_TOKEN_PROVIDER) private readonly db: DBSchema,
- private readonly cache: Cache,
- private readonly filesQueries: FilesQueries,
- private readonly sharesQueries: SharesQueries
+ public readonly cache: Cache,
+ private readonly filesQueries: FilesQueries
) {}
spaceExistsForAlias(alias: string): any | undefined {
@@ -90,6 +88,21 @@ export class SpacesQueries {
.where(and(...where))
}
+ spacesQuotaPaths(spaceId?: number): Promise<(Partial<Space> & { externalPaths: string[] })[]> {
+ return this.db
+ .select({
+ id: spaces.id,
+ alias: spaces.alias,
+ storageUsage: spaces.storageUsage,
+ storageQuota: spaces.storageQuota,
+ externalPaths: sql<string[]>`JSON_ARRAYAGG(${spacesRoots.externalPath})`.mapWith(JSON.parse).as('externalPaths')
+ })
+ .from(spaces)
+ .leftJoin(spacesRoots, and(eq(spacesRoots.spaceId, spaces.id), isNotNull(spacesRoots.externalPath)))
+ .where(and(...[...(spaceId ? [eq(spaces.id, spaceId)] : [])]))
+ .groupBy(spaces.id)
+ }
+
async userIsSpaceManager(userId: number, spaceId: number, shareId?: number): Promise<boolean> {
/* Check if user is a space manager */
const q = this.db
diff --git a/backend/src/applications/spaces/services/spaces-scheduler.service.ts b/backend/src/applications/spaces/services/spaces-scheduler.service.ts
index 9cf6d3f2..ef27ef35 100644
--- a/backend/src/applications/spaces/services/spaces-scheduler.service.ts
+++ b/backend/src/applications/spaces/services/spaces-scheduler.service.ts
@@ -6,36 +6,42 @@
import { Injectable, Logger } from '@nestjs/common'
import { Cron, CronExpression, Timeout } from '@nestjs/schedule'
+import { SharesManager } from '../../shares/services/shares-manager.service'
import { SpacesManager } from './spaces-manager.service'
@Injectable()
export class SpacesScheduler {
private readonly logger = new Logger(SpacesScheduler.name)
- constructor(private readonly spacesManager: SpacesManager) {}
+ constructor(
+ private readonly spacesManager: SpacesManager,
+ private readonly sharesManager: SharesManager
+ ) {}
@Timeout(60000)
@Cron(CronExpression.EVERY_HOUR)
- async updatePersonalSpacesQuota() {
- this.logger.log(`${this.updatePersonalSpacesQuota.name} - START`)
+ async updateQuotas() {
+ this.logger.log('Update Personal Quotas - START')
try {
await this.spacesManager.updatePersonalSpacesQuota()
} catch (e) {
- this.logger.error(`${this.updatePersonalSpacesQuota.name} - ${e}`)
+ this.logger.error(`Update Personal Quotas} - ${e}`)
}
- this.logger.log(`${this.updatePersonalSpacesQuota.name} - END`)
- }
-
- @Timeout(60000)
- @Cron(CronExpression.EVERY_HOUR)
- async updateSpacesQuota() {
- this.logger.log(`${this.updateSpacesQuota.name} - START`)
+ this.logger.log('Update Personal Quotas - END')
+ this.logger.log('Update Space Quotas - START')
try {
await this.spacesManager.updateSpacesQuota()
} catch (e) {
- this.logger.error(`${this.updateSpacesQuota.name} - ${e}`)
+ this.logger.error(`Update Space Quotas - ${e}`)
+ }
+ this.logger.log('Update Space Quotas - END')
+ this.logger.log('Update Share External Path Quotas - START')
+ try {
+ await this.sharesManager.updateSharesExternalPathQuota()
+ } catch (e) {
+ this.logger.error(`Update Share External Path Quotas - ${e}`)
}
- this.logger.log(`${this.updateSpacesQuota.name} - END`)
+ this.logger.log('Update Share External Path Quotas - END')
}
@Cron(CronExpression.EVERY_DAY_AT_4AM)
diff --git a/backend/src/applications/spaces/utils/paths.ts b/backend/src/applications/spaces/utils/paths.ts
index 04e647e3..12b8670f 100644
--- a/backend/src/applications/spaces/utils/paths.ts
+++ b/backend/src/applications/spaces/utils/paths.ts
@@ -11,7 +11,7 @@ import { FileDBProps } from '../../files/interfaces/file-db-props.interface'
import { FileProps } from '../../files/interfaces/file-props.interface'
import { FileError } from '../../files/models/file-error'
import { UserModel } from '../../users/models/user.model'
-import { CACHE_QUOTA_SPACE_PREFIX, CACHE_QUOTA_USER_PREFIX } from '../constants/cache'
+import { CACHE_QUOTA_SHARE_PREFIX, CACHE_QUOTA_SPACE_PREFIX, CACHE_QUOTA_USER_PREFIX } from '../constants/cache'
import { SPACE_REPOSITORY } from '../constants/spaces'
import { SpaceEnv } from '../models/space-env.model'
import { SpaceModel } from '../models/space.model'
@@ -185,21 +185,19 @@ export function dbFileFromSpace(userId: number, space: SpaceEnv): FileDBProps {
export function quotaKeyFromSpace(userId: number, space: SpaceEnv) {
if (space.inPersonalSpace) {
- // personal user space
+ // Personal user space
return `${CACHE_QUOTA_USER_PREFIX}-${userId}`
} else if (space.root?.externalPath) {
- // external paths are managed by admin, set a quota on a root is not intended
- return null
+ // External paths used as shares or as space roots share the same quota as their origin
+ if (space.inSharesRepository) {
+ return `${CACHE_QUOTA_SHARE_PREFIX}-${space.root?.externalParentShareId || space.id}`
+ }
+ return `${CACHE_QUOTA_SPACE_PREFIX}-${space.id}`
} else if (space.root.file?.path && space.root.owner?.login) {
- // space root is linked on a user file
+ // Space root is linked on a user file
return `${CACHE_QUOTA_USER_PREFIX}-${space.root.owner.id}`
} else if (space.root.file?.space?.id) {
- if (space.root.file.root?.id) {
- // share linked to a root space with an external path, set a quota on a root is not intended
- return null
- } else {
- return `${CACHE_QUOTA_SPACE_PREFIX}-${space.root.file.space.id}`
- }
+ return `${CACHE_QUOTA_SPACE_PREFIX}-${space.root.file.space.id}`
} else if (space.id) {
return `${CACHE_QUOTA_SPACE_PREFIX}-${space.id}`
} else {
diff --git a/backend/src/applications/sync/services/sync-manager.service.ts b/backend/src/applications/sync/services/sync-manager.service.ts
index c5e69895..7681d4fa 100644
--- a/backend/src/applications/sync/services/sync-manager.service.ts
+++ b/backend/src/applications/sync/services/sync-manager.service.ts
@@ -148,7 +148,7 @@ export class SyncManager {
throw new HttpException('Space not found', HttpStatus.NOT_FOUND)
}
if (space.quotaIsExceeded) {
- throw new HttpException('Space quota is exceeded', HttpStatus.INSUFFICIENT_STORAGE)
+ throw new HttpException('Storage quota exceeded', HttpStatus.INSUFFICIENT_STORAGE)
}
if (!(await isPathExists(space.realPath))) {
throw new HttpException(`Remote path not found : ${syncPathSettings.remotePath}`, HttpStatus.NOT_FOUND)
diff --git a/backend/src/applications/sync/services/sync-paths-manager.service.spec.ts b/backend/src/applications/sync/services/sync-paths-manager.service.spec.ts
index fab6d1e0..a44961bb 100644
--- a/backend/src/applications/sync/services/sync-paths-manager.service.spec.ts
+++ b/backend/src/applications/sync/services/sync-paths-manager.service.spec.ts
@@ -135,7 +135,7 @@ describe(SyncPathsManager.name, () => {
})
})
- it('should throw INSUFFICIENT_STORAGE when space quota is exceeded', async () => {
+ it('should throw INSUFFICIENT_STORAGE when storage quota is exceeded', async () => {
const req = baseReq()
req.space.quotaIsExceeded = true
await expect(service.createPath(req, { remotePath: 'x' } as any)).rejects.toMatchObject({
diff --git a/backend/src/applications/sync/services/sync-paths-manager.service.ts b/backend/src/applications/sync/services/sync-paths-manager.service.ts
index b1cd5be6..c994fe1b 100644
--- a/backend/src/applications/sync/services/sync-paths-manager.service.ts
+++ b/backend/src/applications/sync/services/sync-paths-manager.service.ts
@@ -43,7 +43,7 @@ export class SyncPathsManager {
throw new HttpException('Client id is missing', HttpStatus.BAD_REQUEST)
}
if (req.space.quotaIsExceeded) {
- throw new HttpException('Space quota is exceeded', HttpStatus.INSUFFICIENT_STORAGE)
+ throw new HttpException('Storage quota exceeded', HttpStatus.INSUFFICIENT_STORAGE)
}
if (!(await isPathExists(req.space.realPath))) {
throw new HttpException(`Remote path not found : ${syncPathDto.remotePath}`, HttpStatus.NOT_FOUND)
diff --git a/backend/src/common/interfaces.ts b/backend/src/common/interfaces.ts
index 8fef171a..4cd45594 100644
--- a/backend/src/common/interfaces.ts
+++ b/backend/src/common/interfaces.ts
@@ -5,3 +5,8 @@
*/
export type Entries<T> = { [K in keyof T]: [K, T[K]] }[keyof T][]
+
+export interface StorageQuota {
+ storageUsage: number
+ storageQuota: number
+}
diff --git a/frontend/src/app/applications/shares/components/dialogs/share-dialog.component.html b/frontend/src/app/applications/shares/components/dialogs/share-dialog.component.html
index 36488f0c..555891a3 100644
--- a/frontend/src/app/applications/shares/components/dialogs/share-dialog.component.html
+++ b/frontend/src/app/applications/shares/components/dialogs/share-dialog.component.html
@@ -56,14 +56,38 @@
[(ngModel)]="share.description"
class="form-control form-control-sm">
</div>
- <div class="mb-3 px-0">
- <label for="switchStatus" l10nTranslate>Share status</label>
- <div class="d-flex align-items-center form-check form-switch cursor-pointer">
- <input class="form-check-input" [(ngModel)]="share.enabled" id="switchStatus" type="checkbox" role="button">
- <label class="form-check-label mb-0 ms-2" for="switchStatus" l10nTranslate>
- {{ share.enabled ? 'enabled' : 'disabled' }}
- </label>
+ @if (share.externalPath) {
+ <div class="d-flex flex-column align-items-start mb-3">
+ <app-storage-quota [(quota)]="share.storageQuota" [fullWidth]="true" class="w-100"></app-storage-quota>
</div>
+ @if (share.storageUsage) {
+ <div class="d-flex flex-column mb-3">
+ <label for="storage" l10nTranslate>Storage Usage</label>
+ <app-storage-usage id="storage" [item]="share"></app-storage-usage>
+ </div>
+ }
+ }
+ <div class="d-flex justify-content-between">
+ <div>
+ <label for="switchStatus" l10nTranslate>Share status</label>
+ <div class="d-flex align-items-center form-check form-switch cursor-pointer">
+ <input class="form-check-input" [(ngModel)]="share.enabled" id="switchStatus" type="checkbox" role="button">
+ <label class="form-check-label mb-0 ms-2" for="switchStatus" l10nTranslate>
+ {{ share.enabled ? 'enabled' : 'disabled' }}
+ </label>
+ </div>
+ </div>
+ @if (share.externalPath) {
+ <div>
+ <label for="switchFullText" l10nTranslate>Full-text search</label>
+ <div class="d-flex align-items-center form-check form-switch cursor-pointer">
+ <input class="form-check-input" [(ngModel)]="share.storageIndexing" id="switchFullText" type="checkbox" role="button">
+ <label class="form-check-label mb-0 ms-2" for="switchFullText" l10nTranslate>
+ {{ share.storageIndexing ? 'enabled' : 'disabled' }}
+ </label>
+ </div>
+ </div>
+ }
</div>
</div>
</div>
diff --git a/frontend/src/app/applications/shares/components/dialogs/share-dialog.component.ts b/frontend/src/app/applications/shares/components/dialogs/share-dialog.component.ts
index 6c2696d1..cf5d92c4 100644
--- a/frontend/src/app/applications/shares/components/dialogs/share-dialog.component.ts
+++ b/frontend/src/app/applications/shares/components/dialogs/share-dialog.component.ts
@@ -18,6 +18,8 @@ import { BsModalRef } from 'ngx-bootstrap/modal'
import { TabsModule } from 'ngx-bootstrap/tabs'
import { Observable } from 'rxjs'
import { take } from 'rxjs/operators'
+import { StorageQuotaComponent } from '../../../../common/components/storage-quota.component'
+import { StorageUsageComponent } from '../../../../common/components/storage-usage.component'
import { AutofocusDirective } from '../../../../common/directives/auto-focus.directive'
import { TimeDateFormatPipe } from '../../../../common/pipes/time-date-format.pipe'
import { pathSlice } from '../../../../common/utils/functions'
@@ -51,7 +53,9 @@ import { ShareRepositoryComponent } from '../utils/share-repository.component'
UserSearchComponent,
ShareRepositoryComponent,
ShareFileNameComponent,
- FilePermissionsComponent
+ FilePermissionsComponent,
+ StorageQuotaComponent,
+ StorageUsageComponent
],
templateUrl: 'share-dialog.component.html'
})
diff --git a/frontend/src/app/applications/shares/models/share.model.ts b/frontend/src/app/applications/shares/models/share.model.ts
index 7de3272d..770bfaf3 100644
--- a/frontend/src/app/applications/shares/models/share.model.ts
+++ b/frontend/src/app/applications/shares/models/share.model.ts
@@ -24,6 +24,9 @@ export class ShareModel implements ShareProps {
description: string
enabled: boolean
externalPath: string
+ storageUsage: number
+ storageQuota: number
+ storageIndexing: boolean
createdAt: Date
modifiedAt: Date
disabledAt: Date
diff --git a/frontend/src/app/applications/shares/services/shares.service.ts b/frontend/src/app/applications/shares/services/shares.service.ts
index 27ede6c2..a2fcdb6d 100644
--- a/frontend/src/app/applications/shares/services/shares.service.ts
+++ b/frontend/src/app/applications/shares/services/shares.service.ts
@@ -76,6 +76,7 @@ export class SharesService {
name: '',
createdAt: new Date(),
modifiedAt: new Date(),
+ storageIndexing: true,
enabled: true,
...(isSharesRepo ? { parent: { id: 0, ownerId: 0, alias: file.space.alias, name: file.space.name } } : {})
}
diff --git a/frontend/src/i18n/fr.json b/frontend/src/i18n/fr.json
index a30d6928..fe738702 100644
--- a/frontend/src/i18n/fr.json
+++ b/frontend/src/i18n/fr.json
@@ -146,8 +146,8 @@
"Storage Quota": "Quota de stockage",
"Storage Usage": "Utilisation du stockage",
"Space status": "État de l'espace",
- "Space quota is exceeded": "Le quota de l'espace dépassé",
- "Quota will be exceeded": "Le quota sera dépassé",
+ "Storage quota exceeded": "Le quota de stockage est dépassé",
+ "Storage quota will be exceeded": "Le quota de stockage sera dépassé",
"No more space available": "Plus d'espace disponible",
"available_space_is_low": "Espace disponible faible ( {{ nb }}% )",
"online": "en ligne",