Ver código fonte

cleanup depot when using delete db command

Guénaël Muller 6 anos atrás
pai
commit
adf1dd1659
1 arquivos alterados com 12 adições e 2 exclusões
  1. 12 2
      tracim/command/database.py

+ 12 - 2
tracim/command/database.py Ver arquivo

@@ -3,6 +3,7 @@ import argparse
3 3
 
4 4
 import plaster_pastedeploy
5 5
 import transaction
6
+from depot.manager import DepotManager
6 7
 from pyramid.paster import (
7 8
     get_appsettings,
8 9
     setup_logging,
@@ -113,10 +114,19 @@ class DeleteDBCommand(AppContextCommand):
113 114
         setup_logging(config_uri)
114 115
         settings = get_appsettings(config_uri)
115 116
         engine = get_engine(settings)
117
+        app_config = CFG(settings)
118
+        app_config.configure_filedepot()
119
+
116 120
         if parsed_args.force:
117
-            print('Database deletion begin')
121
+            print('Database deletion begin.')
118 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 130
         else:
121 131
             print('Warning, You should use --force if you really want to'
122 132
                   ' delete database.')