Changeset 478
- 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
| r477 |
r478 |
|
| 255 | 255 | '''Remove a directory from control by the store. Note: this removes its entry not its control files unless the directory is "."''' |
|---|
| 256 | 256 | if name == '.': |
|---|
| | 257 | for x in os.listdir(self.storage_dir): |
|---|
| | 258 | os.remove(os.path.join(self.storage_dir, x)) |
|---|
| 257 | 259 | 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)) |
|---|
| 259 | 266 | os.rmdir(self.nodes_dir) |
|---|
| 260 | 267 | os.remove(self.status_path) |
|---|
| … | … | |
| 1133 | 1140 | self.layers[self.root].config.set('general', 'root', self.root) |
|---|
| 1134 | 1141 | 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])) |
|---|
| 1136 | 1143 | for e in self.entries.keys(): |
|---|
| 1137 | 1144 | self.layers[os.path.join(os.path.dirname(self.root), self.entries[e].group)].config.set('entries', e, pickle.dumps(self.entries[e])) |
|---|
| … | … | |
| 1172 | 1179 | old_classification = self.classification |
|---|
| 1173 | 1180 | 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) |
|---|
| 1177 | 1184 | new_dirs.append(os.path.join(os.path.dirname(self.root), classification, self.id)) |
|---|
| 1178 | 1185 | new_dirs.sort() |
|---|
| 1179 | | cl = Layer(os.path.join(os.path.dirname(self.root), classification)) |
|---|
| 1180 | 1186 | 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) |
|---|
| 1182 | 1196 | else: |
|---|
| 1183 | 1197 | 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() |
|---|
| 1185 | 1201 | for o in old_dirs: |
|---|
| 1186 | 1202 | if o not in new_dirs: |
|---|
| … | … | |
| 1201 | 1217 | self.set_file_status(f, nl.storage.path, 0) |
|---|
| 1202 | 1218 | 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 |
|---|
| 1203 | 1222 | nl.update() |
|---|
| 1204 | 1223 | self.classify() |
|---|
Download in other formats:
* Generating other formats may take time.