##// END OF EJS Templates
app: ensure largefile dirs are created on application startup.
marcink -
r1651:a9881962 default
parent child Browse files
Show More
@@ -54,7 +54,7 b' from rhodecode.lib.plugins.utils import '
54 from rhodecode.lib.utils2 import aslist as rhodecode_aslist
54 from rhodecode.lib.utils2 import aslist as rhodecode_aslist
55 from rhodecode.subscribers import (
55 from rhodecode.subscribers import (
56 scan_repositories_if_enabled, write_metadata_if_needed,
56 scan_repositories_if_enabled, write_metadata_if_needed,
57 write_js_routes_if_enabled)
57 write_js_routes_if_enabled, create_largeobjects_dirs_if_needed)
58
58
59
59
60 log = logging.getLogger(__name__)
60 log = logging.getLogger(__name__)
@@ -303,6 +303,7 b' def includeme(config):'
303 settings['default_locale_name'] = settings.get('lang', 'en')
303 settings['default_locale_name'] = settings.get('lang', 'en')
304
304
305 # Add subscribers.
305 # Add subscribers.
306 config.add_subscriber(create_largeobjects_dirs_if_needed, ApplicationCreated)
306 config.add_subscriber(scan_repositories_if_enabled, ApplicationCreated)
307 config.add_subscriber(scan_repositories_if_enabled, ApplicationCreated)
307 config.add_subscriber(write_metadata_if_needed, ApplicationCreated)
308 config.add_subscriber(write_metadata_if_needed, ApplicationCreated)
308 config.add_subscriber(write_js_routes_if_enabled, ApplicationCreated)
309 config.add_subscriber(write_js_routes_if_enabled, ApplicationCreated)
@@ -229,6 +229,33 b' def write_js_routes_if_enabled(event):'
229 f.write(jsroutes_file_content)
229 f.write(jsroutes_file_content)
230
230
231
231
232 def create_largeobjects_dirs_if_needed(event):
233 """
234 This is subscribed to the `pyramid.events.ApplicationCreated` event. It
235 does a repository scan if enabled in the settings.
236 """
237 from rhodecode.lib.utils import get_rhodecode_base_path
238 from rhodecode.lib.vcs.backends.hg import largefiles_store
239 from rhodecode.lib.vcs.backends.git import lfs_store
240
241 repo_store_path = get_rhodecode_base_path()
242
243 paths = [
244 largefiles_store(repo_store_path),
245 lfs_store(repo_store_path)]
246
247 for path in paths:
248 if os.path.isdir(path):
249 continue
250 if os.path.isfile(path):
251 continue
252 # not a file nor dir, we try to create it
253 try:
254 os.makedirs(path)
255 except Exception:
256 log.warning('Failed to create largefiles dir:%s', path)
257
258
232 class Subscriber(object):
259 class Subscriber(object):
233 """
260 """
234 Base class for subscribers to the pyramid event system.
261 Base class for subscribers to the pyramid event system.
General Comments 0
You need to be logged in to leave comments. Login now