Changeset 7592
- Timestamp:
- 2004-06-14T17:28:15+12:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java
r7526 r7592 1416 1416 1417 1417 try { 1418 // We have to ensure that the local library 1418 // We have to ensure that the local library doesn't have locks on any files 1419 1419 if(!Gatherer.GS3 && Gatherer.config.exec_file != null) { 1420 ///ystem.err.println("Local Library Found!");1421 //Gatherer.g_man./review_pane.configServer(GSDLSiteConfig.RELEASE_COMMAND + collection.getName());1422 1420 Gatherer.self.configServer(GSDLSiteConfig.RELEASE_COMMAND + collection.getName()); 1423 1421 } 1424 1422 1425 File index_dir = new File(getCollectionIndex(), "temp.txt"); 1426 index_dir = index_dir.getParentFile(); 1427 if(index_dir.exists()) { 1428 Gatherer.println("Index = " + index_dir.getAbsolutePath()); 1429 } 1430 1431 File build_dir = new File(getCollectionBuild(), "temp.txt"); 1432 build_dir = build_dir.getParentFile(); 1423 File build_dir = new File(getCollectionBuild()); 1433 1424 Gatherer.println("Build = " + build_dir.getAbsolutePath()); 1434 1425 1435 // Get the build mode from the build options 1436 String build_mode = collection.build_options.getBuildValue("mode"); 1437 1438 // Special case for build mode "all": replace index dir with building dir 1439 if (build_mode == null || build_mode.equals(Dictionary.get("CreatePane.Mode_All"))) { 1440 // Remove the old index directory 1441 if (index_dir.exists()) { 1442 Utility.delete(index_dir); 1443 // Check the delete worked 1444 if (index_dir.exists()) { 1445 throw new Exception("Index directory cannot be removed."); 1446 } 1447 } 1448 1449 // Move the building directory to become the new index directory 1450 if (build_dir.renameTo(index_dir) == false) { 1451 throw new Exception("Build directory cannot be moved."); 1452 } 1453 1454 // Create a new building directory 1455 File new_build = new File(getCollectionBuild(), "temp.txt"); 1456 new_build = new_build.getParentFile(); 1457 new_build.mkdir(); 1458 } 1459 1460 // Otherwise copy everything in the building dir into the index dir 1461 else { 1462 File[] build_files = build_dir.listFiles(); 1463 for (int i = 0; i < build_files.length; i++) { 1464 File build_file = build_files[i]; 1465 File index_equivalent = new File(index_dir, build_file.getName()); 1466 1467 // Remove the old file in the index directory (if it exists) 1468 if (index_equivalent.exists()) { 1469 Utility.delete(index_equivalent); 1470 // Check the delete worked 1471 if (index_equivalent.exists()) { 1472 throw new Exception("Index file " + index_equivalent + " cannot be removed."); 1473 } 1474 } 1475 1476 // Move the file into the index directory 1477 if (build_file.renameTo(index_equivalent) == false) { 1478 throw new Exception("File " + build_file + " cannot be moved into index directory."); 1479 } 1480 } 1481 } 1482 1426 // Make sure an index directory exists to move files into 1427 File index_dir = new File(getCollectionIndex()); 1428 if (!index_dir.exists()) { 1429 index_dir.mkdir(); 1430 } 1431 Gatherer.println("Index = " + index_dir.getAbsolutePath()); 1432 1433 moveContentsInto(build_dir, index_dir, true); 1483 1434 } 1484 1435 catch (Exception exception) { … … 1486 1437 return false; 1487 1438 } 1439 1488 1440 return true; 1489 1441 } 1442 1443 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) 1446 { 1447 File[] source_files = source_directory.listFiles(); 1448 for (int i = 0; i < source_files.length; i++) { 1449 File source_file = source_files[i]; 1450 File target_file = new File(target_directory, source_file.getName()); 1451 1452 if (source_file.isDirectory()) { 1453 moveContentsInto(source_file, target_file, overwrite); 1454 source_file.delete(); 1455 } 1456 else { 1457 if (target_file.exists() && overwrite) { 1458 target_file.delete(); 1459 source_file.renameTo(target_file); 1460 } 1461 } 1462 } 1463 } 1464 1490 1465 1491 1466 private boolean searchArchivesForMetadata(File archive_directory) {
Note:
See TracChangeset
for help on using the changeset viewer.