Changeset 478

Show
Ignore:
Timestamp:
05/22/08 10:56:23 (8 months ago)
Author:
jmowery
Message:

fixed reclassifying nodes to properly clean up files in old classification directories

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/trunk-pmd-intproto/server/storage.py

    r477 r478  
    255255                '''Remove a directory from control by the store. Note: this removes its entry not its control files unless the directory is "."''' 
    256256                if name == '.': 
     257                        for x in os.listdir(self.storage_dir): 
     258                                os.remove(os.path.join(self.storage_dir, x)) 
    257259                        os.rmdir(self.storage_dir) 
    258                         os.rmdir(self.logs_dir) 
     260                        if self.logs_dir == os.path.join(self.path, '.__logs__'): 
     261                                for x in os.listdir(self.logs_dir): 
     262                                        os.remove(os.path.join(self.logs_dir, x)) 
     263                                os.rmdir(self.logs_dir) 
     264                        for x in os.listdir(self.nodes_dir): 
     265                                os.remove(os.path.join(self.nodes_dir, x)) 
    259266                        os.rmdir(self.nodes_dir) 
    260267                        os.remove(self.status_path) 
     
    11331140                self.layers[self.root].config.set('general', 'root', self.root) 
    11341141                for b in self.bools.keys(): 
    1135                         self.layers[self.root].config.set('bools', b, str(bools[b])) 
     1142                        self.layers[self.root].config.set('bools', b, str(self.bools[b])) 
    11361143                for e in self.entries.keys(): 
    11371144                        self.layers[os.path.join(os.path.dirname(self.root), self.entries[e].group)].config.set('entries', e, pickle.dumps(self.entries[e])) 
     
    11721179                        old_classification = self.classification 
    11731180                        old_dirs = self.list_layers() 
    1174                         _l = get_layer_by_group(self.root, classification) 
    1175                         new_dirs = collect_dirs(_l.storage.path, _l.storage.root) 
    1176                         new_dirs.append(_l.storage.path) 
     1181                        cl = get_layer_by_group(self.root, classification) 
     1182                        new_dirs = collect_dirs(cl.storage.path, cl.storage.root) 
     1183                        new_dirs.append(cl.storage.path) 
    11771184                        new_dirs.append(os.path.join(os.path.dirname(self.root), classification, self.id)) 
    11781185                        new_dirs.sort() 
    1179                         cl = Layer(os.path.join(os.path.dirname(self.root), classification)) 
    11801186                        if os.path.basename(old_classification) == self.id: 
    1181                                 shutil.copytree(_l.storage.path, os.path.join(os.path.dirname(self.root), classification, self.id)) 
     1187                                prev_l = get_layer_by_group(self.root, old_classification) 
     1188                                if prev_l.storage.path in old_dirs: 
     1189                                        old_dirs.remove(prev_l.storage.path) 
     1190                                        del self.layers[prev_l.storage.path] 
     1191                                shutil.copytree(prev_l.storage.path, os.path.join(os.path.dirname(self.root), classification, self.id)) 
     1192                                prev_l.remove('.') 
     1193                                for x in os.listdir(prev_l.name): 
     1194                                        os.remove(os.path.join(prev_l.name, x)) 
     1195                                os.rmdir(prev_l.name) 
    11821196                        else: 
    11831197                                os.mkdir(os.path.join(os.path.dirname(self.root), classification, self.id)) 
    1184                         cl.add(os.path.join(os.path.dirname(self.root), classification, self.id)) 
     1198                        cl.add(self.id) 
     1199                        cl.entries[self.id].type = 'LOCAL' 
     1200                        cl.update() 
    11851201                        for o in old_dirs: 
    11861202                                if o not in new_dirs: 
     
    12011217                                                self.set_file_status(f, nl.storage.path, 0) 
    12021218                                        self.layers[n].write() #create the file 
     1219                                if os.path.basename(nl.name) == self.id: 
     1220                                        nl.entries['.'].type = 'LOCAL' 
     1221                                        nl.modified = True 
    12031222                                nl.update() 
    12041223                        self.classify()