Skip to main content

Meta File System (MFS)

MFS, for Meta File System, is Drumee's internal file management layer. Unlike standard web applications that expose the host file system directly to application logic, MFS adds a full abstraction layer that makes file handling safer, more flexible, and permission-aware at every level.

MFS principle

Why MFS Exists

Standard applications that work directly with the host file system face several structural problems:

  • The entire host file system is potentially reachable if the application has a vulnerability
  • There is no built-in concept of ownership or per-user isolation
  • Moving, copying, or trashing files requires writing custom logic in every service
  • No unified way to attach metadata (MIME type, category, visibility) to files

MFS solves all of these by storing the logical representation of files and folders in a database and keeping physical files in an isolated, content-addressed storage directory. The application never constructs raw filesystem paths from user input.

Core Concepts

Nodes

Everything in MFS is a node. A node can be:

CategoryDescription
folderA directory that contains other nodes
fileAn uploaded file (document, image, video, etc.)
hubA special root folder that belongs to a Hub (shared workspace)

Each node has a unique id (UUID), an owner_id, a parent_id pointing to its container, and a set of metadata fields including filename, mimetype, category, filesize, and extension.

Physical Storage

Physical files live under a content-addressed path:

{mfs_dir}/{VFS_ROOT_NODE}/{node_id}/

The application never exposes this path to the client. Downloads and uploads go through MFS service endpoints that perform permission checks before any I/O.

The Media Table

The central database table is media. Every node in every hub and every personal drive is a row in a media table. Each Hub and each user has its own database, so the media table is scoped per owner. Cross-hub queries use Drumee's stored procedure convention of prefixing the database name.

Key columns:

ColumnDescription
idUUID — primary key and physical storage address
parent_idUUID of the parent folder node
owner_idUUID of the owning user
filenameInternal filename
user_filenameDisplay name shown to users
mimetypeMIME type of the file
categoryLogical type: folder, file, hub, etc.
filesizeSize in bytes
extensionFile extension without the dot
metadataJSON blob for arbitrary additional data
showVisibility flag
ctimeCreation Unix timestamp
mtimeLast modification Unix timestamp

Trash System

Deleted nodes are not immediately removed. They are moved to a trash_media table with a trashed_time timestamp. This allows users to restore files within a configurable expiry window. Once the expiry period passes, the expiry worker permanently deletes the physical files and purges the database record.

Key Stored Procedures

MFS operations are performed exclusively through stored procedures. Services never run raw SQL against the media table directly.

ProcedurePurpose
mfs_create_nodeCreate a new file or folder node
mfs_moveMove a node to a different parent
mfs_copyCopy a node and its children
mfs_trash_mediaSoft-delete: move node to trash
mfs_restoreRestore a node from trash
mfs_purgeHard-delete a node record
mfs_empty_trashPermanently delete all expired trash nodes
mfs_manifestGet the full recursive file list under a node
mfs_access_nodeCheck whether a user can access a given node
mfs_get_byFetch a node record by various criteria

Permission Model

Every MFS node carries a permission level. Drumee uses a bitwise permission system:

LevelValueWho
anonymous0Public, no authentication
read2Any authenticated user with read access
write4Users with write access
admin6Hub administrators
owner7The node owner

The permission_grant procedure assigns a privilege level to a specific entity (user, group, or wildcard *) on a node for a defined duration. The permission_revoke procedure removes it.

Service Layer Integration

MFS services receive a resolved node via this.granted_node() or this.source_granted(). These methods perform the ACL check and return the node object only if the current user has sufficient privilege. A service never needs to check permissions manually — the ACL configuration in the JSON file handles the gate, and granted_node() provides the already-verified result.

Example service pattern:

async move() {
const node = this.granted_node(); // permission already checked
const pid = this.input.need('pid'); // required: destination folder id
await this.db.await_proc('mfs_move', node.id, pid);
this.output.data({ nid: node.id });
}

SEO Integration

When a file is created or modified, Drumee can register it in the seo_index and seo_register tables. This enables the platform's internal search engine to index documents without exposing file paths directly. The SEO indexing pipeline runs asynchronously and does not block file operations.