- Timestamp:
- 2004-06-17T11:08:27+12:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java
r7592 r7601 1167 1167 if(installCollection()) { 1168 1168 // If we have a local library running (that we know about) then we ask it to add our newly create collection 1169 if (Gatherer.config.exec_file != null) {1169 if (Gatherer.config.exec_file != null) { 1170 1170 Gatherer.self.configServer(GSDLSiteConfig.ADD_COMMAND + collection.getName()); 1171 } else if (Gatherer.GS3) { 1171 // This is very important -- it ensures that the above command has finished 1172 Gatherer.self.configServer(""); 1173 } 1174 else if (Gatherer.GS3) { 1172 1175 convertToGS3Collection(); 1173 1176 Gatherer.self.configGS3Server(Gatherer.config.site_name, ServletConfiguration.ADD_COMMAND + collection.getName()); … … 1177 1180 Gatherer.g_man.collectionChanged(ready()); 1178 1181 1179 // Now display a message dialog saying its all built1180 WarningDialog collection_built_warning_dialog = new WarningDialog("warning.CollectionBuilt", false);1181 collection_built_warning_dialog.setMessageOnly(true); // Not a warning1182 collection_built_warning_dialog.display();1183 collection_built_warning_dialog.dispose();1184 collection_built_warning_dialog = null;1182 // Now display a message dialog saying its all built 1183 WarningDialog collection_built_warning_dialog = new WarningDialog("warning.CollectionBuilt", false); 1184 collection_built_warning_dialog.setMessageOnly(true); // Not a warning 1185 collection_built_warning_dialog.display(); 1186 collection_built_warning_dialog.dispose(); 1187 collection_built_warning_dialog = null; 1185 1188 } 1186 1189 else { … … 1416 1419 1417 1420 try { 1418 // We have to ensure that the local library doesn't have locks on any files1419 if (!Gatherer.GS3 && Gatherer.config.exec_file != null) {1421 // We have to ensure that the local library has released this collection so we can delete the index directory 1422 if (!Gatherer.GS3 && Gatherer.config.exec_file != null) { 1420 1423 Gatherer.self.configServer(GSDLSiteConfig.RELEASE_COMMAND + collection.getName()); 1421 } 1422 1423 File build_dir = new File(getCollectionBuild());1424 Gatherer.println("Build = " + build_dir.getAbsolutePath());1425 1426 // Make sure an index directory exists to move files into 1424 1425 // This is very important -- it ensures that the above command has finished 1426 // This prevents the nasty "could not remove index directory" race condition! 1427 Gatherer.self.configServer(""); 1428 } 1429 1427 1430 File index_dir = new File(getCollectionIndex()); 1428 if (!index_dir.exists()) {1429 index_dir.mkdir();1430 }1431 1431 Gatherer.println("Index = " + index_dir.getAbsolutePath()); 1432 1432 1433 moveContentsInto(build_dir, index_dir, true); 1433 File building_dir = new File(getCollectionBuild()); 1434 Gatherer.println("Building = " + building_dir.getAbsolutePath()); 1435 1436 // Get the build mode from the build options 1437 String build_mode = collection.build_options.getBuildValue("mode"); 1438 1439 // Special case for build mode "all": replace index dir with building dir 1440 if (build_mode == null || build_mode.equals(Dictionary.get("CreatePane.Mode_All"))) { 1441 // Remove the old index directory 1442 if (index_dir.exists()) { 1443 Utility.delete(index_dir); 1444 // Check the delete worked 1445 if (index_dir.exists()) { 1446 throw new Exception("Index directory could not be removed."); 1447 } 1448 } 1449 1450 // Move the building directory to become the new index directory 1451 if (building_dir.renameTo(index_dir) == false) { 1452 throw new Exception("Build directory could not be moved."); 1453 } 1454 } 1455 1456 // Otherwise copy everything in the building dir into the index dir 1457 else { 1458 moveContentsInto(building_dir, index_dir); 1459 } 1434 1460 } 1435 1461 catch (Exception exception) { … … 1437 1463 return false; 1438 1464 } 1439 1440 1465 return true; 1441 1466 } 1442 1467 1443 1468 1444 /** Moves all the files in one directory into another, overwriting if desired*/1445 private void moveContentsInto(File source_directory, File target_directory , boolean overwrite)1469 /** Moves all the files in one directory into another, overwriting existing files */ 1470 private void moveContentsInto(File source_directory, File target_directory) 1446 1471 { 1447 1472 File[] source_files = source_directory.listFiles(); … … 1451 1476 1452 1477 if (source_file.isDirectory()) { 1453 moveContentsInto(source_file, target_file , overwrite);1478 moveContentsInto(source_file, target_file); 1454 1479 source_file.delete(); 1455 1480 } 1456 1481 else { 1457 if (target_file.exists() && overwrite) {1482 if (target_file.exists()) { 1458 1483 target_file.delete(); 1459 source_file.renameTo(target_file);1460 1484 } 1485 1486 source_file.renameTo(target_file); 1461 1487 } 1462 1488 }
Note:
See TracChangeset
for help on using the changeset viewer.