linagora / twake-drive

The open-source alternative to Google Drive.
GNU Affero General Public License v3.0
45 stars 14 forks source link

With S3 storage, if `STORAGE_S3_HOME_DIRECTORY != "tdrive"` files aren't uploaded nor downloaded correctly #562

Open ericlinagora opened 1 month ago

ericlinagora commented 1 month ago

Describe the bug Using the following environment (or any environment with S3 and without STORAGE_S3_HOME_DIRECTORY=tdrive):

ACCOUNTS_TYPE=internal
STORAGE_DRIVER=S3

STORAGE_S3_BUCKET=tdrive-dev
STORAGE_S3_ENDPOINT=localhost
STORAGE_S3_ACCESS_KEY=minio
STORAGE_S3_SECRET_KEY=miniopassword

# including for completeness only:
DB_DRIVER=mongodb
SEARCH_DRIVER=mongodb
PUBSUB_TYPE=local

There is however a file in the FS of the bucket at:

tdrive-dev/tdrive/files/d56f4e70-2342-11ef-8d0f-238afbd3c611/d5611da0-2342-11ef-8d0f-238afbd3c611/06054f26-89ee-442b-9cf1-73d168d4519f/chunk1

Note the missing /tdrive/ in the logs

ericlinagora commented 1 month ago

Issue goes away with STORAGE_S3_HOME_DIRECTORY=tdrive, but reappears with STORAGE_S3_HOME_DIRECTORY=plop: during_upload_with_plop_home.log

It searches for:

plop/files/d56f4e70-2342-11ef-8d0f-238afbd3c611/d5611da0-2342-11ef-8d0f-238afbd3c611/bc277481-05ad-4055-b8b7-b7846608ea67/chunk1

This time the bucket name is missing, it should be tdrive-dev/plop/files...

ericlinagora commented 1 month ago

Issue probably here https://github.com/linagora/twake-drive/blob/main/tdrive/backend/node/src/core/platform/services/storage/index.ts#L75 , value read before and after getConnector was called, because it changes during the run without the var/config set from '/tdrive' to 'tdrive-dev'