clear:uploads

Table of contents

  1. Introduction
  2. Clearing the production uploads
  3. Where it runs
  4. Which directory
  5. Reference
    1. Options
    2. Output
    3. Requirements
  6. See also

Introduction

clear:uploads empties PROTECTED_UPLOADS_DIR, where the active product’s app keeps the files it serves behind an access check. The directory itself stays, and the public files under static/ are not touched. db:reset and product:clean run it too.

splent clear:uploads
Delete every file in /workspace/my_product/src/instance/protected_uploads? What the features stored there, and the app serves from it, cannot be recovered. [y/N]: y
The contents of the uploads directory /workspace/my_product/src/instance/protected_uploads have been successfully cleared.

Clearing the production uploads

splent clear:uploads --prod --yes

--prod targets the production deployment, <product>_web_deploy. Without it the command targets development, <product>_web, unless SPLENT_ENV=prod. --yes skips the question, for scripts.


Where it runs

PROTECTED_UPLOADS_DIR is a path inside the product’s web container, and in production a volume only that container mounts. So the command goes where the files are.

The product’s web container What happens
Running The command runs again inside it, with --yes passed on
Down, in development It runs in the CLI container, which sees the same files. When the production container is running beside it, it says These are the development uploads. <product>_web_deploy is running: 'splent clear:uploads --prod' empties its own.
Down, in production It deletes nothing and says <product>_web_deploy is not running, and its uploads are in a volume only it mounts. Nothing was deleted from here. Exit 0

product:clean --prod reaches the last row after down -v, which already removed the volume.


Which directory

The command finds the directory the way the framework’s protected_uploads_dir() does.

  1. PROTECTED_UPLOADS_DIR in the app’s config, when the caller has the app, as db:reset does.
  2. PROTECTED_UPLOADS_DIR in the environment, which every command loads from the product’s env files.
  3. protected_uploads in the app’s instance folder. For a product that runs from its source tree, as in development, that is <product>/src/instance/protected_uploads.

It refuses, and deletes nothing, when the path is relative, the root, a system directory such as /etc or /usr, your home, the workspace, the product or its package, holds any of them, or has pyproject.toml, setup.py, .git or __init__.py at its top.

Symlinks inside the directory are removed, never followed.


Reference

Options

Option Description
--dev The development environment, <product>_web. The default, unless SPLENT_ENV=prod
--prod The production environment, <product>_web_deploy
-y, --yes Do not ask for confirmation

Output

Output Meaning
The contents of the uploads directory <path> have been successfully cleared. Everything inside was deleted
The uploads directory <path> does not exist. Nothing to do
Error clearing the uploads directory <path>. Could not delete <n> entries. Some entries are left, one line each. Exit 1
Cannot clear the uploads directory. <reason> Nothing was deleted. The path is one an uploads directory cannot be. Exit 1
Cannot specify both --dev and --prod. Pass only one. Exit 1

Requirements

  • An active product (SPLENT_APP).

See also

  • db:reset empties the uploads after dropping the tables.
  • product:clean runs it with --yes, after asking once for everything.
  • Fixtures describes the store a test app keeps its files in, never the product’s.

Back to top

splent. Distributed by an LGPL license v3. Contact us: drorganvidez@us.es