Skip to content

File storage_dir fix & refactor#5204

Closed
timothycarambat wants to merge 9 commits intomasterfrom
5152-file-fix-and-refactor
Closed

File storage_dir fix & refactor#5204
timothycarambat wants to merge 9 commits intomasterfrom
5152-file-fix-and-refactor

Conversation

@timothycarambat
Copy link
Member

Pull Request Type

  • ✨ feat (New feature)
  • 🐛 fix (Bug fix)
  • ♻️ refactor (Code refactoring without changing behavior)
  • 💄 style (UI style changes)
  • 🔨 chore (Build, CI, maintenance)
  • 📝 docs (Documentation updates)

Relevant Issues

resolves #5152

Description

Patches issue with container hotdir resolution.

Visuals (if applicable)

Additional Information

Refactored a ton of the use of file paths across the application.
Normalize storage path resolution across server and collector
Centralizes all storage path constants into single source-of-truth exports:

  • server: baseStoragePath, documentsPath, directUploadsPath, vectorCachePath, hotdirPath
  • collector: basePrimaryStoragePath, WATCH_DIRECTORY, tmpStorage, documentsFolder

This eliminates scattered NODE_ENV/STORAGE_DIR ternaries throughout the codebase and ensures consistent path resolution between server and collector.

Other changes:

  • Fix hotdirPath to correctly point to collector/storage/hotdir in development
  • Add ensureRequiredDirectoriesExist() to create storage dirs on collector startup
  • Add path traversal protection in downloadURIToFile
  • Add eslint-plugin-import for unresolved import detection
  • Remove static placeholder files (now created dynamically)

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated (if applicable)
  • I have tested my code functionality
  • Docker build succeeds locally

Normalize storage path resolution across server and collector

Centralizes all storage path constants into single source-of-truth exports:
- server: baseStoragePath, documentsPath, directUploadsPath, vectorCachePath, hotdirPath
- collector: basePrimaryStoragePath, WATCH_DIRECTORY, tmpStorage, documentsFolder

This eliminates scattered NODE_ENV/STORAGE_DIR ternaries throughout the codebase
and ensures consistent path resolution between server and collector.

Other changes:
- Fix hotdirPath to correctly point to collector/storage/hotdir in development
- Add ensureRequiredDirectoriesExist() to create storage dirs on collector startup
- Add path traversal protection in downloadURIToFile
- Add eslint-plugin-import for unresolved import detection
- Remove static placeholder files (now created dynamically)
@timothycarambat timothycarambat added the PR: Ready for QA Indicates that a PR is ready for QA and the GH image may build the image label Mar 13, 2026
@timothycarambat timothycarambat added PR:Ready-to-merge PR has been reviewed by core team and is ready to merge and removed PR: Ready for QA Indicates that a PR is ready for QA and the GH image may build the image PR:Ready-to-merge PR has been reviewed by core team and is ready to merge labels Mar 13, 2026
@timothycarambat
Copy link
Member Author

TODO: Custom startup has broken DB path:

export STORAGE_LOCATION=$HOME/anythingllm && \
mkdir -p $STORAGE_LOCATION && \
touch "$STORAGE_LOCATION/.env" && \
docker run -d -p 3001:3001 \
--cap-add SYS_ADMIN \
-v ${STORAGE_LOCATION}:/workspace \
-v ${STORAGE_LOCATION}/.env:/workspace/.env \
-e STORAGE_DIR="/workspace" \
ghcr.io/mintplex-labs/anything-llm:pr-5204

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: ENOENT: /collector/hotdir when STORAGE_DIR is not /app/server/storage

1 participant