Feature #5298

Store attachments in sub directories

Added by Istvan DEMETER over 7 years ago. Updated about 4 years ago.

Status:ClosedStart date:2010-04-13
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Attachments
Target version:2.3.0
Resolution:Fixed

Description

To prevent Redmine's storage_path's (by default: File.join RAILS_ROOT, 'files') index growing too large (we have so many file-s there, that accessing to the this directory was getting to become slow).

Files already present in the storage will still available, but the newly uploaded file will be storeg in a subdirectory.

The directory structure: RAILS_ROOT/files/1004/25/100425124312_filname_or_hash.extension.

Happy pathcing :)

0001-Store-file-in-y-m-d-format-sub-dir-to-prevent-direct.patch Magnifier (1.65 KB) Istvan DEMETER, 2010-04-13 01:22

system_error.png (7.33 KB) Mohamed Ahmed, 2013-09-24 17:35

trace.txt Magnifier (14.5 KB) Mohamed Ahmed, 2013-09-24 17:43


Related issues

Duplicated by Redmine - Feature #9908: The /files directory should contain attachments in subdir... Closed
Duplicated by Redmine - Feature #2228: Multilevel upload dirs to accomodate 1000's of files Closed 2008-11-25

Associated revisions

Revision 10990
Added by Jean-Philippe Lang almost 5 years ago

Store attachments in subdirectories (#5298).

Existing files can be moved to their target subdirectories using rake redmine:attachments:move_to_subdirectories.

Revision 10993
Added by Jean-Philippe Lang almost 5 years ago

NoMethodError: private method `now' called for DateTime:Class error in tests with ruby < 1.9.3 (#5298).

History

#1 Updated by Jean-Philippe Lang almost 5 years ago

  • Tracker changed from Patch to Feature
  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang
  • Target version set to 2.3.0
  • Resolution set to Fixed

Feature added in r10990. Attachments are now stored in subdirectories per month (eg. 2012/12).

A rake task was added to move existing files to their target subdirectories:

rake redmine:attachments:move_to_subdirectories

#2 Updated by Hannes Meier almost 5 years ago

THANK YOU SO MUCH!

JA IST DENN HEUT SCHON WEIHNACHTEN?

(engl.: is it already christmas eve?)

#3 Updated by Mohamed Ahmed about 4 years ago

Failed to run on my machine, Windows 2012 Server x64
Bitnami ruby stack v1.9.3-14 installed to C:\BitNami\rubystack-1.9.3-14

Environment:
  • Redmine version 2.3.3.stable
  • Ruby version 1.9.3-p231 (2012-05-25) [i386-mingw32]
  • Rails version 3.2.13
  • Environment production
  • Database adapter Mysql2
    Redmine plugins:
  • no plugin installed

And here is the Trace file

#4 Updated by Mohamed Ahmed about 4 years ago

Also available in: Atom PDF