Self-hosted Google Drive clone
  • Python 50.3%
  • JavaScript 31.8%
  • CSS 11.7%
  • HTML 4.6%
  • Shell 1.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
P7MJ 9ffbfacc14 Update Markdown sidebar incrementally after file operations
Preserve unrelated cached folders and DOM rows after confirmed mutations. Open new documents from the creation result without rereading them, maintain Recent metadata, and cover remote CRUD request counts and cache updates.
2026-12-02 20:09:49 -05:00
drive_storage Let a drive borrow storage from other operators 2026-11-25 20:59:57 -05:00
driveapp Update Markdown sidebar incrementally after file operations 2026-12-02 20:09:49 -05:00
scripts Unify Drive and Markdown UI and fix document editing 2026-12-02 12:17:46 -05:00
static Update Markdown sidebar incrementally after file operations 2026-12-02 20:09:49 -05:00
templates Unify Drive and Markdown UI and fix document editing 2026-12-02 12:17:46 -05:00
tests Update Markdown sidebar incrementally after file operations 2026-12-02 20:09:49 -05:00
.gitignore Init Commit 2026-10-09 22:28:58 -04:00
app.py Add administration, Drive UI, and systemd lifecycle tooling 2026-11-01 21:04:46 -05:00
install-storage.sh Let a drive borrow storage from other operators 2026-11-25 20:59:57 -05:00
install.sh Storage nodes 2026-11-23 13:34:27 -05:00
README.md Update Markdown sidebar incrementally after file operations 2026-12-02 20:09:49 -05:00
requirements.txt Init Commit 2026-10-09 22:28:58 -04:00
serve.py Storage nodes 2026-11-23 13:34:27 -05:00
storage_server.py Let a drive borrow storage from other operators 2026-11-25 20:59:57 -05:00
uninstall-storage.sh Let a drive borrow storage from other operators 2026-11-25 20:59:57 -05:00
uninstall.sh Rebrand the application as [w] Drive 2026-11-19 18:10:40 -05:00

[w] Drive

A self-hosted private drive for Debian/Linux, using Flask, SQLite, Waitress, and a plain JavaScript frontend. Designed for a trusted LAN. Each account has its own private filesystem root.

Formerly P7MJ Drive. Existing installations retain the p7mj-drive service/CLI name, installation paths, P7MJ_DRIVE_* settings, and saved URL prefix for upgrade compatibility. The application is now branded [w] Drive.

Features

  • Drive-inspired responsive interface, light/dark themes, list/grid views, breadcrumbs, browser navigation, search, sorting, multi-select, and keyboard shortcuts.
  • Files and folder uploads, drag-and-drop, progress, cancel/retry, and upload recovery after a server restart. Files up to 1 GiB, chunks up to 25 MiB, and at most ten simultaneous chunk requests.
  • Move, copy, rename, stars, recent files, folder ZIP downloads, trash/restore, permanent deletion, and file details.
  • Browse unencrypted ZIPs as read-only folders and extract them here, here with the original moved to Trash, or into a folder chosen with the destination browser.
  • Image, audio, video (including QuickTime .mov), PDF, and plain-text/source previews with byte-range media seeking. Text previews and edits are limited to 5 MiB. Uploaded HTML, scripts, and SVG are never rendered as executable documents; SVG is shown as source text only.
  • /md, a [w] Markdown editor: reading view for rendered GitHub-flavoured Markdown, a raw source editor with syntax highlighting, and a file tree for either this browser or My Drive. See Markdown editor.
  • Read-only sharing links for files and folders: selected accounts or anyone with the link, expiration, download controls, and owner revocation.
  • Federated storage: link community or personal [w] Drive nodes with a one-time invitation code. Each grant adds real capacity to the same account, files are spread across the volumes, and a linked node can stay headless (no web UI) without ever seeing file names, folders, or other accounts.
  • /admin for account creation, roles, disabling/reactivation, password resets, session revocation, quotas, account deletion, public registration, service storage information, and administrative activity.
  • Administrators manage accounts and storage; they do not receive access to users' private files through the application.
  • SQLite schema migrations preserve existing accounts and files. Existing users remain ordinary users until explicitly promoted.
  • systemd installation, a saved configurable port, non-destructive uninstallation, and offline backup/restore commands.

Install on Debian

Install prerequisites, then run the installer from this project directory:

sudo apt update
sudo apt install -y python3 python3-venv
sudo ./install.sh

Installation requires root privileges. Use sudo ./install.sh; running ./install.sh directly also attempts to elevate through sudo. Administrative CLI commands likewise use sudo p7mj-drive ....

The installer asks you to create an account or name an existing account to promote to administrator. It installs dependencies from requirements.txt, creates a dedicated p7mj-drive system account, and enables p7mj-drive.service.

By default, it listens on all IPv4 interfaces and chooses the first available port in 8765–8864. The port is saved in /etc/p7mj-drive/drive.env and reused across restarts, upgrades, and reinstalls. You can choose the initial address and port:

sudo ./install.sh --host 192.168.1.202 --port 8765

Open http://<server-LAN-IP>:<saved-port> and visit /admin after signing in. Public registration starts disabled; ordinary accounts receive a 10 GiB quota. Quota 0 means unlimited.

Port availability is checked during first installation. If another application later occupies the saved port, the service reports a binding failure in its journal rather than changing the URL. Keep this LAN-only; do not port-forward the service. A later HTTPS reverse-proxy deployment must also set P7MJ_DRIVE_HTTPS=1 for secure cookies.

If installation reports runuser: failed to execute /opt/p7mj-drive/venv/bin/python: Permission denied, update this checkout and rerun sudo ./install.sh. The installer ensures application files and virtual-environment directories are readable/traversable by the service account, even when the calling shell uses a restrictive umask. Configuration and user data remain private. Reinstallation preserves existing configuration and files.

Installed paths and management

Path Contents
/opt/p7mj-drive Application, lifecycle scripts, and virtual environment
/etc/p7mj-drive/drive.env Protected secret, data directory, host, port, HTTPS cookie setting
/var/lib/p7mj-drive Database, user files, trash, temporary uploads, retired accounts, restore recovery copies
/usr/local/bin/p7mj-drive Administrative CLI wrapper
sudo systemctl status p7mj-drive
sudo journalctl -u p7mj-drive -f
sudo systemctl restart p7mj-drive
sudo p7mj-drive create-user
sudo p7mj-drive set-admin USERNAME
sudo p7mj-drive reset-password USERNAME
sudo p7mj-drive registration off

set-admin explicitly promotes an existing account, reactivates it if disabled, and revokes old sessions. This is also the local recovery route when an administrator loses access. The web interface prevents disabling, deleting, or demoting the last active administrator.

To update, obtain the new source and run its sudo ./install.sh again. Dependencies are staged before stopping the service. Existing configuration, secret, database, user data, and port are retained. Back up before updating; a failed update after the service is stopped may require rerunning installation. Host/port overrides on a subsequent installation are rejected to avoid silently changing existing configuration. Edit the protected configuration and restart to change them deliberately.

The installer uses the fixed paths above. Keep P7MJ_DRIVE_DATA at its installed value when using the bundled service and uninstaller. Custom data paths require corresponding systemd permissions and manual data removal.

Changing your password

Any signed-in user can open the account menu (the avatar at the top right of the drive), choose Change password, and enter their current password and the new password twice. New passwords must be 12–1024 characters. A successful change signs out all sessions, including the current one, and returns to sign-in with a confirmation message. Incorrect current-password attempts are throttled. This only changes your own account; no administrator access is needed.

If you have forgotten your current password, an administrator can reset it from /admin or with sudo p7mj-drive reset-password USERNAME.

Hosting under an existing domain and path

[w] Drive can run at https://git.wholeworldcoding.com/p7mj-drive/ alongside an existing site. Its pages then live at /p7mj-drive/drive, /p7mj-drive/admin, and /p7mj-drive/login. Links, redirects, uploads, downloads, previews, and SVG assets use the configured prefix.

Update the installed application with sudo ./install.sh, then edit /etc/p7mj-drive/drive.env:

P7MJ_DRIVE_HOST=127.0.0.1
P7MJ_DRIVE_PREFIX=/p7mj-drive
P7MJ_DRIVE_HTTPS=1

Keep the existing port setting (the example below uses 8765). Restart with sudo systemctl restart p7mj-drive. An empty prefix, the default, serves the app at /. Nested prefixes such as /apps/drive also work. Changing the prefix requires signing in again; sessions use a dedicated cookie scoped to that path.

Add these locations inside the existing HTTPS server block for your domain, alongside the locations serving Git or other applications:

location = /p7mj-drive {
    return 308 /p7mj-drive/;
}

location ^~ /p7mj-drive/ {
    # No trailing slash: preserve /p7mj-drive in the upstream request.
    proxy_pass http://127.0.0.1:8765;
    proxy_set_header Host $host;
    proxy_redirect off;
    client_max_body_size 26m;
    proxy_read_timeout 300s;
}

Validate and reload your Nginx configuration using sudo nginx -t and sudo systemctl reload nginx. The app handles the prefix itself; do not strip it at the proxy or set X-Forwarded-Prefix. It does not trust forwarded headers to choose its mount path. The chunked uploader only needs a request limit slightly larger than its 25 MiB chunks, even for larger files.

This preserves the existing site's /admin, /api, and /static paths: Drive's corresponding requests stay below /p7mj-drive/. Requests reaching the Drive backend outside its configured prefix return 404. Cookies are scoped to reduce accidental conflicts, but applications sharing a hostname still share a browser origin; use a separate subdomain if you need browser-origin isolation. Existing LAN-first security limitations still apply when considering public access.

This setup follows Flask's WSGI dispatching model and Nginx's URI-preserving proxy behavior.

Markdown editor

/md is a dedicated Markdown workspace. Opening a file shows the rendered document with Preview and Raw tabs, the file's last-modified time, and no formatting toolbar; Edit swaps in Write and Preview tabs for editing. Text previews in My Drive offer Open in Markdown for the file you are looking at. The left sidebar offers two storage backends:

  • This browser keeps documents in IndexedDB (not shared between browsers or devices).
  • My Drive browses the same private drive as /drive and saves through the existing text endpoints.

Any UTF-8 text file can be opened for reading or editing; files that are binary, larger than 5 MiB, or HTML/JavaScript/SVG are reported as unsupported. New documents can use any text extension such as .md or .txt. Saving is revision-checked, so two tabs cannot silently overwrite each other, and edits are written in place with the drive's normal permissions and quota.

The editor renders GitHub-flavoured Markdown — tables, task lists, strikethrough, autolinks, footnotes, alert callouts, and collapsible sections — then sanitizes the result, so embedded HTML cannot run scripts. Images hosted on other sites are blocked by default; the editor asks once, and Markdown settings changes the choice later. Loading remote images reveals your IP address to their host.

Drive and Markdown share the same top bar, account-menu styling, and light/dark preference. Drive's gear menu contains the Admin link for administrators. Theme changes are saved to your account, including across separate app subdomains when signed into the same account. Other open tabs update when focused or during their periodic preference check. The saved theme is applied before the interface renders; existing browser-local preferences are adopted when an account has no saved preference.

Drive search updates while you type, with a short debounce and one listing request in flight at a time. Clearing a search returns to the folder you were browsing. The Markdown sidebar defaults to 260 px; drag its right edge between 200 and 480 px. Focus the divider and use the arrow keys, Home, or End to resize with the keyboard; double-click it to reset. The chosen width is saved in this browser. Mobile continues to use the files drawer.

Markdown updates affected sidebar entries after confirmed creates, renames, moves, and deletes, preserving unrelated folder caches. New empty documents open from the creation result without an extra file read. Use Refresh to reconcile changes made in another tab or app.

Markdown login links preserve the requested document and storage choice through sign-in, including paths with spaces or Unicode characters.

Serving it from a subdomain

Set P7MJ_DRIVE_MD_HOSTS in /etc/p7mj-drive/drive.env to a comma-separated list of hosts. Those hosts serve the editor at / and treat other paths as document deep links, while /md, /static, /api, /login, and /admin keep working normally:

P7MJ_DRIVE_MD_HOSTS=md.wholeworldcoding.com

Point the host at the same upstream, for example in a separate Nginx server block:

server {
    listen 443 ssl;
    server_name md.wholeworldcoding.com;

    location / {
        proxy_pass http://127.0.0.1:8765;
        proxy_set_header Host $host;
        proxy_redirect off;
        client_max_body_size 26m;
    }
}

When P7MJ_DRIVE_PREFIX is set, deep links are forwarded below that prefix (/p7mj-drive/md/...). Sessions are host-scoped, so sign in separately on the subdomain; that keeps the drive cookie off unrelated hosts under the same parent domain. Restart the service after changing drive.env.

Uninstall

./uninstall.sh

This stops and disables the service, removes its unit and CLI wrapper, and deletes only the application and virtual environment. It preserves configuration, the secret, accounts, uploaded files, trash, retired-account archives, and restore recovery copies. Reinstalling reuses them. The service account is retained so preserved files retain their owner.

To permanently remove all application-managed configuration and data as well:

./uninstall.sh --purge

You must type DELETE ALL DATA before anything is stopped or deleted. This cannot be undone. Backups saved outside the application's directories are untouched. You can also run /opt/p7mj-drive/uninstall.sh while the application is installed. A source checkout outside /opt/p7mj-drive remains available after uninstallation.

Existing v0.1 installations

For an existing manual installation, stop its server and back up its entire data directory and secret. To adopt the managed installation, copy that data directory's contents into /var/lib/p7mj-drive before running the installer. After the system account exists, ensure it owns the copied data (sudo chown -R p7mj-drive:p7mj-drive /var/lib/p7mj-drive). Alternatively, install once, stop the service, replace the fresh data with your backup, fix ownership, and rerun the installer to designate an existing account as administrator.

A new installer-generated secret signs out old sessions but does not affect password hashes or file data. For manual development against the existing data directory, schema migration happens on application import; use the original secret if desired. Existing accounts never automatically become admins.

The SQLite database stores stable IDs, stars, recent-file timestamps, trash locations, quotas, audit entries, and active uploads. File contents remain ordinary files. Manage files through the application to keep metadata consistent; external renames cannot preserve file identity automatically.

Backups and restoration

Stop the server before copying the database and file trees together. The supplied server holds a lock so backup/restore commands refuse to run against a running installed service, even when --offline is supplied.

sudo systemctl stop p7mj-drive
sudo p7mj-drive backup /path/writable-by-service-account/drive-backup --offline
sudo systemctl start p7mj-drive

The destination must not already exist and must be outside the data directory. The backup contains a consistent SQLite snapshot, active files, trash, retired accounts, temporary uploads, and the chunks this server keeps for linked-storage drives. Chunks stored on linked nodes are not included; their operators own those copies, so treat them like remote storage nodes when planning recovery. Back up /etc/p7mj-drive separately to retain configuration and the secret. Backup directories are private. Put backups on a different disk when possible.

sudo systemctl stop p7mj-drive
sudo p7mj-drive restore /path/to/drive-backup --offline --confirm
sudo systemctl start p7mj-drive

Restoration retains the previous data under /var/lib/p7mj-drive/recovery/<timestamp>. These local recovery copies are not included in subsequent backups and can be removed manually after verifying restoration. Interrupted uploads are discarded on restore, since their temporary paths may belong to another installation. The backup itself remains unchanged.

Sharing files and folders

Use Share… from a file or folder's action menu. Choose Selected users and pick active accounts, or Anyone with the link for access without sign-in. Optionally set an expiration and disable downloads, then press Create link and Copy link. On plain HTTP, browsers without clipboard access select the link so you can copy it manually. Opening Share again edits the item's existing link.

Open the avatar menu → Manage shares to copy links, edit access or expiration, and revoke a link. Revocation takes effect on subsequent requests; a revoked link is never reused. Creating another link for the item generates a different token. Selected users must sign in with an allowed account; sign-in returns them to the shared item. Administrators have no automatic bypass for other users' selected-account links.

Recipients get a dedicated read-only page with folder navigation and safe text/image/audio/video previews. They cannot edit, upload, rename, delete, or create additional links for the owner's files through that page. Downloads include individual files and folder ZIPs only when enabled. Disabling downloads hides those actions and blocks the download endpoints; content that can be previewed can still be copied or saved. Shared ZIP files can be downloaded when allowed but are not browsed or extracted through a sharing link.

Links follow the existing stable file IDs when files or folders are renamed or moved through the app. Folder links include the folder's current contents and future additions. Moving a shared item or an ancestor to Trash makes its links unavailable; restoration can make unexpired, unrevoked links available again. Purging the item or deleting its owner removes the links. Disabling the owner makes every link unavailable, and disabled recipients lose selected-account access. Recreating a deleted username does not inherit that account's old links or permissions.

Sharing URLs work under the configured URL prefix. Copy links using the hostname recipients can reach; a localhost or LAN-only address will not become publicly reachable merely because a link is set to “Anyone.” Link tokens are secrets stored in the private database and included in backups. Shared responses are not cached or indexed and suppress the referrer header. Migration adds stable internal account keys and sharing tables automatically; no file contents are moved. Password-protected links, write access, upload links, and invitations are deferred.

Browsing and extracting ZIP archives

Open a .zip file to browse it in the same list/grid interface as an ordinary folder. Breadcrumbs navigate the archive's folders, browser back/forward and reload retain your location, and search filters the current archive folder. Archive members have no selection, preview, download, rename, or other item actions. This view only reads directory metadata; it does not extract contents. Downloading the original ZIP from its normal file menu remains available.

Use Extract… at the top of the ZIP browser, or from the ZIP's normal file menu:

  • Extract here places the archive's contents alongside the original ZIP, preserving the internal folder structure.
  • Extract here and delete extracts there and moves the original ZIP to Trash only after successful extraction. It can be restored normally.
  • Extract to… opens a compact folder browser with breadcrumbs; browse into the destination folder and press Extract.

Extraction applies to the entire ZIP, including when you are viewing a folder inside it. Existing files or folders are never overwritten or merged: a conflicting top-level name stops the operation before extraction. Choose another destination or resolve the conflict first. Files are decompressed into private staging storage, checked for integrity, and placed in the destination only after all entries are read successfully. Ordinary failures roll back newly placed items and preserve the original ZIP. Restarting the supplied server removes abandoned ZIP staging directories after a crash. As with other filesystem operations, a power failure during final placement can require manual recovery.

Only unencrypted .zip files are supported. Encrypted entries, split archives, unsupported compression methods, duplicate/conflicting paths, symlinks, special files, and unsafe paths are rejected. Stored, Deflate, BZIP2, and LZMA compression are supported. Limits are 10,000 archive entries, 20,000 directory nodes including inferred folders, 64 path components, an 8 MiB central directory, 1 GiB of total expanded data, and a 64 MiB LZMA dictionary. Extraction checks available disk space and the user's quota, including pending uploads; choosing the delete option does not bypass quota because the ZIP remains in Trash.

Uploads and storage

Uploads reserve their complete size against quota before accepting chunks; trash counts toward quota. Admin-retained files from deleted accounts are stored under retired/ and consume server disk space without belonging to a live user's quota.

Active upload state is persisted after each successful chunk. The server recovers acknowledged offsets and truncates uncommitted partial data on startup. The transfer tray offers reselection of the original file after a reload/restart. Identity checks use file size and modification time; HTTPS adds a hash of the first and last 64 KiB. This is a practical identity check, not a full-file checksum. Interrupted uploads expire after six hours of inactivity; cleanup occurs on startup and upload activity. No completed file is overwritten by an upload.

Use serve.py as the single production server process. Multiple server processes against the same data directory are unsupported; the supplied launcher prevents them with a filesystem lock. SQLite and filesystem operations are not one atomic transaction: a power loss during a file move, trash operation, or account deletion may require recovery from backup. Upload finalization itself uses an atomic filesystem rename.

Storage-only nodes

The main server can use other servers for whole users’ drives. It remains responsible for accounts, quotas, sharing, authorization, placement, and the committed file index. Nodes store file chunks and replicas; users continue to use the main server’s URL. One main server controls a node installation. Main must remain online for access and changes. Run main through the supplied serve.py/systemd service so its reconciliation worker runs.

On each storage server, install from this checkout:

sudo ./install-storage.sh
# Or choose its initial persistent port:
sudo ./install-storage.sh --port 8766
sudo systemctl status w-drive-storage
sudo journalctl -u w-drive-storage -n 100

The installer creates w-drive-storage.service, /opt/w-drive-storage (application/venv), /etc/w-drive-storage/node.env (private pairing key and saved port), and /var/lib/w-drive-storage (file data). It listens only on 127.0.0.1; the first available port in 8766–8865 is selected and saved. Reinstalling preserves the key, port, limits, and data. Root can read the pairing key from node.env; treat it as a credential with full access to that node. Node keys and custom CA certificates are stored privately in main’s database and are excluded from admin API responses.

Expose the node through an HTTPS reverse proxy with a certificate trusted by main and the other nodes. For example, within an existing nginx HTTPS server block on the node, using its saved port:

location /drive-storage/ {
    proxy_pass http://127.0.0.1:8766/;
    proxy_request_buffering off;
    proxy_buffering off;
    proxy_read_timeout 300s;
    client_max_body_size 32m;
}

Register https://storage.example.com/drive-storage and the pairing key in Admin → Storage nodes → Add storage node. A private CA’s PEM certificate can be entered in the same dialog. HTTPS certificates are always verified; HTTP endpoints and redirects are rejected. Main and replica nodes must be able to reach each other’s registered HTTPS URLs. Peer transfers use short-lived read capabilities for individual chunks, rather than giving peers each other’s pairing keys.

Placement and a main server with no file storage

In Admin → Storage nodes, configure whether main stores user files, main’s primary user limit (-1 means unlimited), and each node’s primary user limit and byte budget. Main is preferred while enabled and below its user limit. A node’s limit counts primary users only; replicas use disk space but do not consume primary-user slots. Set a node’s user limit to zero to use it only for replicas. Every user’s complete drive, including trash, stays together on one primary group.

For a main server with little disk space, disable “Store user files on main” and set its user limit to zero. Main will never be selected as a replica. For a fresh manual deployment, P7MJ_DRIVE_LOCAL_STORAGE=0 supplies this initial setting; afterwards the saved admin setting takes precedence. Main still needs space for the app, SQLite metadata, logs, and updates, but remote uploads have no local file/part cache. Main forwards bounded chunks in memory; remote ZIP extraction and folder ZIP generation run on a node. Configure any HTTPS proxy in front of main to disable request/response buffering too, so the proxy does not spool uploads or downloads to main’s disk.

Existing local files stay in place until migrated. After registering storage, use Move a user’s drive or enable automatic migration to drain main. Disabling main cancels unfinished local uploads so they cannot block the drain. Drives awaiting a move remain readable, with file changes paused. Migration verifies destination chunks and manifests before switching placement; it preserves file IDs and share links, then removes old local file copies to release space. An unavailable destination does not replace the source with an empty drive. Finish or cancel active remote uploads before migrating that user.

Automatic migration is opt-in for existing deployments. When enabled, it also moves users on Unreliable storage toward Reliable storage once usage, including trash, exceeds 20% of their allocated quota. Users with unlimited quotas prefer Reliable storage. A missing destination slot or insufficient capacity produces an admin warning; no files are discarded to satisfy placement limits. Admins can queue a verified move to a specific destination regardless of this preference. New accounts are assigned when they first access file APIs.

Replication, outages, and repair

Label a primary Unreliable, choose one or more other nodes as its replicas, and configure “Allow changes when a required replica is unavailable.” Pairing is configured on the primary; each selected node holds a complete copy regardless of its own classification.

  • Disabled (default): users can read an available current copy, but file changes wait until all required copies are ready.
  • Enabled: uploads and other file changes may commit on available current copies. When a node returns, it mirrors main’s committed state from the current copies, including moves and deletions. A stale returning copy cannot accept changes until it catches up.

Under normal operation, required nodes confirm checksummed chunks and a durable prepared manifest before main commits a change. Main tries the primary for reads and falls back to a current replica. Repair runs before queued migrations and transfers missing chunks directly between nodes. Availability/version checks run each worker cycle, and unchanged drives receive checksum scrubs approximately every five minutes; reads verify the chunks they use. The authoritative file index lives on main; unexplained disk or manifest changes on a node are repaired from that index and verified peer copies. Never edit node files directly.

A Reliable primary has no automatic replica. If it goes down, affected users see an explicit unavailable-storage message instead of an empty/new drive, and file changes fail. Admin links and the storage panel turn red when storage needs attention; the panel lists node status, assignments, affected users, and migration errors. Health is polled approximately every 15 seconds in the UI. With no surviving verified copy, repair reports an error and waits for recovery; it cannot reconstruct lost content.

Deleted/unreferenced chunks are collected after a six-hour grace period; active upload chunks and retained account data are protected. Node byte budgets and disk reserve can temporarily prevent uploads even after logical deletion. Corrupt chunks are quarantined for diagnosis and require manual cleanup after recovery. The default node reserve is 256 MiB (W_DRIVE_NODE_RESERVE in node.env); the admin byte budget is persisted by the node and takes precedence over its initial W_DRIVE_NODE_CAPACITY value.

Replication propagates legitimate deletions and is not historical backup. Back up main’s database/configuration and all node data directories, stopping main and nodes for a consistent snapshot. The existing main-only backup/restore CLI does not include remote blobs. Restoring an older main database makes its saved manifests authoritative, so restore matching node snapshots before restarting. Keep main’s database safe: nodes alone cannot recreate accounts, share links, or the committed file index. The node service is single-process; multi-main clustering is not supported.

Removing a storage service

sudo ./uninstall-storage.sh
# Permanently destroy this node’s config, credential, and file data:
sudo ./uninstall-storage.sh --purge

Default removal stops the service and removes its app/venv/unit while preserving config and data. Purge requires typing DELETE ALL NODE DATA. Use Unregister in the admin panel after moving assigned drives and removing replica references; retained deleted-account drives also prevent unregistration. Uninstalling does not migrate anything. Do not purge a node that holds the only surviving copy. The protected system account is retained so a reinstall can reuse preserved data.

Federated storage (linked community nodes)

One organisation can run [w] Drive while a user's drive draws capacity from storage offered by someone else. This is the Mastodon-style model: you keep a single account here and may link capacity from a community group, a friend's server, or your own second installation. This server stays authoritative for accounts, quota, sharing, and the file index; a linked node holds only the file chunks covered by the grant it issued.

A linked node does not need the web interface at all. The storage-only service from install-storage.sh is enough, which is the usual way to contribute capacity to a community.

Offering capacity from a node

On the node's host, with no accounts or UI required:

sudo w-drive-storage-peer peer add --label "Community pool" --quota 100GiB

The command prints a join code once. Send the code together with the node's public HTTPS base URL (the same URL you would register in Admin → Storage nodes, such as https://storage.example.org/drive-storage). Each code creates a separate, budgeted guest area: the node never learns another instance's pairing key, and a guest cannot reach the node owner's own drive data or any other guest.

sudo w-drive-storage-peer peer list
sudo w-drive-storage-peer peer quota <id> 250GiB
sudo w-drive-storage-peer peer revoke <id>   # immediate access loss, data kept
sudo w-drive-storage-peer peer remove <id>   # delete the grant and its stored data

Using capacity in your account

Open the account menu → Linked storage, then paste the URL and join code under Add node. Add as many nodes as you like. Your quota becomes your quota here plus every grant, and files are spread across those volumes automatically, so a single drive can be larger than any one node allows. A chunk is placed on the volume with the most room left.

Removing a node copies the chunks it holds to your remaining storage first, then releases the grant and its data on that node. If no other volume has room, removal is refused rather than losing files. Linking the first node moves an existing local drive into the federated layout in the background; changes pause briefly while it does.

What each participant controls

  • This server keeps accounts, quotas, share links, trash, and the authoritative file index, and must be online.
  • A linked node keeps chunks for its grant only. It cannot see file names, folders, or other accounts, and this server never browses or manages that node's contents.
  • Node operators may lower a quota or revoke a code at any time. Files placed there stay readable while the node is reachable; if it disappears, only the files stored on it become unavailable.
  • Deleting an account releases its grants, and each node then removes that guest area.
  • A drive assigned to a managed storage node (Admin → Storage nodes) cannot be linked to community storage; move it off that placement first.

Limitations: ZIP browsing and extraction are not available on linked-storage drives yet; ZIP files can still be uploaded, downloaded, trashed, and restored, and folder downloads are generated by this server. This server still holds the whole index and all quota metadata, so "self-hosting the whole service" means running this application; linked nodes add capacity, not a second source of accounts.

Development and tests

python3 -m venv .venv
.venv/bin/python -m pip install -r requirements.txt
export P7MJ_DRIVE_DATA="$PWD/data"
# Generate and load a development secret without displaying it.
umask 077
.venv/bin/python -c 'import secrets; print(secrets.token_urlsafe(48))' > .secret
export P7MJ_DRIVE_SECRET="$(cat .secret)"
.venv/bin/python -m flask --app app create-user
.venv/bin/python -m flask --app app set-admin USERNAME
P7MJ_DRIVE_HOST=127.0.0.1 P7MJ_DRIVE_PORT=8080 .venv/bin/python serve.py
.venv/bin/python -m unittest discover -s tests -v
node tests/markdown_highlight.cjs
node tests/markdown_open.cjs
node tests/markdown_formatting.cjs
node tests/markdown_tree.cjs
# After changing the bundled w-ui top-bar styles:
python3 scripts/build-appbar.py
node --check static/drive.js
node --check static/admin.js
bash -n install.sh uninstall.sh install-storage.sh uninstall-storage.sh scripts/p7mj-drive

An optional real-browser smoke test uses an existing Firefox installation and Node’s undici WebSocket client:

node tests/browser_smoke.cjs
node tests/browser_smoke.cjs /p7mj-drive

It creates a temporary server and browser profile and reports paths to desktop/mobile screenshots.

Storage integration tests also require openssl; they create disposable HTTPS nodes with verified test certificates and exercise replication, outages, repair, migration, quotas, and upload recovery. Tests use disposable data directories and a v0.1 database fixture. Lifecycle tests run the actual installation/removal logic in a temporary filesystem, replacing privileged ownership commands, package provisioning, and systemd. They need permission to bind a local socket for the port probe. They never install a host service or delete real application data.

Keyboard shortcuts: / focuses search, Ctrl/Cmd+A selects the displayed files, Delete opens the trash/deletion dialog, and Escape clears selection or closes a dialog.

Deferred features include document collaboration, file version history, antivirus scanning, and automatic backup scheduling.

Icon credits

Interface icons use Phosphor Icons in bold and filled styles, bundled locally in static/icons.svg so no external font or CDN is needed. The pinned source revision is recorded in that file; the MIT license is included in static/icons-LICENSE.txt.