Browse Source

cleanup depot when using delete db command

Guénaël Muller 7 years ago
parent
commit
adf1dd1659
1 changed files with 12 additions and 2 deletions
  1. 12 2
      tracim/command/database.py

+ 12 - 2
tracim/command/database.py View File

3
 
3
 
4
 import plaster_pastedeploy
4
 import plaster_pastedeploy
5
 import transaction
5
 import transaction
6
+from depot.manager import DepotManager
6
 from pyramid.paster import (
7
 from pyramid.paster import (
7
     get_appsettings,
8
     get_appsettings,
8
     setup_logging,
9
     setup_logging,
113
         setup_logging(config_uri)
114
         setup_logging(config_uri)
114
         settings = get_appsettings(config_uri)
115
         settings = get_appsettings(config_uri)
115
         engine = get_engine(settings)
116
         engine = get_engine(settings)
117
+        app_config = CFG(settings)
118
+        app_config.configure_filedepot()
119
+
116
         if parsed_args.force:
120
         if parsed_args.force:
117
-            print('Database deletion begin')
121
+            print('Database deletion begin.')
118
             DeclarativeBase.metadata.drop_all(engine)
122
             DeclarativeBase.metadata.drop_all(engine)
119
-            print('Database deletion done')
123
+            print('Database deletion done.')
124
+            print('Cleaning depot begin.')
125
+            depot = DepotManager.get()
126
+            depot_files = depot.list()
127
+            for file in depot_files:
128
+                depot.delete(file)
129
+            print('Cleaning depot done.')
120
         else:
130
         else:
121
             print('Warning, You should use --force if you really want to'
131
             print('Warning, You should use --force if you really want to'
122
                   ' delete database.')
132
                   ' delete database.')