Changeset 6175
- Timestamp:
- 2003-12-08T17:08:03+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/file/FileQueue.java
r5847 r6175 121 121 FileJob job = new FileJob(id, source, child, target, parent, type, undo, undoable); 122 122 job.folder_level = folder_level; 123 ///ystem.err.println("Adding job: " + job);123 Gatherer.println("Adding job: " + job); 124 124 if(position != -1 && position <= queue.size() + 1) { 125 125 queue.add(position, job); … … 413 413 // we just retrieve the metadata attached to the origin node... 414 414 ArrayList existing_metadata = gdm.getMetadataOnly(source_file); 415 // Gatherer.println("Existing metadata for " + origin_node + ": " + gdm.toString(existing_metadata));415 ///atherer.println("Existing metadata for " + origin_node + ": " + gdm.toString(existing_metadata)); 416 416 // then assign this remainder to the new folder. 417 417 ///ystem.err.println("New metadata: " + gdm.toString(existing_metadata)); … … 441 441 // If we haven't been cancelled, and we've been asked to delete a directory/file, or perhaps as part of a move, we delete the file. This involves removing any existing metadata and then copying the file to the recycled bin (for a delete only), then deleting the file. When deleting a directory record from the tree (or from the filesystem for that matter) we must ensure that all of the descendant records have already been removed. If we fail to do this the delete will fail, or you will be bombarded with hundreds of 'Parent node of null not allowed' error messages. Also be aware that if the user has cancelled just this action, because of say a name clash, then we shouldn't do any deleting of any sort dammit. 442 442 if(!cancel_action && ready && (job.type == FileJob.DELETE || job.type == FileJob.MOVE)) { 443 ///ystem.err.print("Delete/Move: " + origin_node + " -> "); 443 ///atherer.println("Delete/Move: " + origin_node); 444 ///atherer.println(queue.size() + " jobs remain in queue"); 444 445 // If the source is an empty directory or a file. Don't do anything to the root node of a tree. 445 446 File[] child_list = source_file.listFiles(); 446 447 if(source_file.isFile() || (child_list != null && (child_list.length == 0 || (child_list.length == 1 && child_list[0].getName().equals(Utility.METADATA_XML))) && origin_node.getParent() != null)) { 447 /// ystem.err.println("File or empty directory.");448 ///atherer.println("File or empty directory."); 448 449 // Delete any metadata.xml still in the directory. 449 450 if(child_list != null && child_list.length == 1) { … … 451 452 } 452 453 453 /// ystem.err.println("Origin is file or is directory and is empty.");454 ///atherer.println("Origin is file or is directory and is empty."); 454 455 // update status area 455 456 String args[] = new String[1]; … … 471 472 FileNode parent_record = (FileNode)origin_node.getParent(); 472 473 // Remove from model 473 SynchronizedTreeModelTools.removeNodeFromParent(source_model, origin_node); 474 if(parent_record != null) { 475 SynchronizedTreeModelTools.removeNodeFromParent(source_model, origin_node); 476 } 474 477 // If we are deleting 475 478 File recycled_file = null; … … 526 529 else if(child_list != null && child_list.length > 0) { 527 530 ///ystem.err.print("Nonempty directory -> "); 528 /// ystem.err.println("Directory is non-empty. Remove children first.");531 ///atherer.println("Directory is non-empty. Remove children first."); 529 532 FileNode recycle_folder_record = null; 530 533 // Don't worry about all this for true file move actions. … … 555 558 origin_node.unmap(); 556 559 origin_node.map(); 557 /// ystem.err.println("Directory has " + origin_node.getChildCount() + " children.");558 ///ystem.err.println("Directory actually has " + child_list.length + " children.");559 for(int i = 0; i < origin_node.getChildCount(); i++) {560 FileNode child_record = (FileNode) origin_node.getChildAt(i);561 addJob(job.ID(), job.source, child_record, job.target, destination_node, FileJob.DELETE, job.undo, false, false, position);562 //if(recycle_folder_record != null) {563 // recycle_folder_mappings.put(child_record, recycle_folder_record);564 //}565 }566 560 ///atherer.println("Directory has " + origin_node.getChildCount() + " children."); 561 ///atherer.println("Directory actually has " + child_list.length + " children."); 562 for(int i = 0; i < origin_node.size(); i++) { 563 FileNode child_record = (FileNode) origin_node.get(i); 564 ///atherer.println("Queuing: " + child_record); 565 addJob(job.ID(), job.source, child_record, job.target, destination_node, FileJob.DELETE, job.undo, false, false, position); 566 //if(recycle_folder_record != null) { 567 // recycle_folder_mappings.put(child_record, recycle_folder_record); 568 //} 569 } 567 570 } 568 571 // Requeue a delete job -after- the children have been dealt with. Remember I've reversed the direction of the queue so sooner is later. Te-he. Also have to remember that we have have followed this path to get here for a move job: Copy Directory -> Queue Child Files -> Delete Directory (must occur after child files) -> Queue Directory. 569 572 // One special case. Do not requeue root nodes. Don't requeue jobs marked as done. 570 573 if(origin_node.getParent() != null && !job.done) { 571 System.err.println("Requeuing: " + origin_node.getFile().getAbsolutePath());574 ///atherer.println("Requeuing: " + origin_node.getFile().getAbsolutePath()); 572 575 job.type = FileJob.DELETE; // You only requeue jobs that are deletes, as directories must be inspected before children, but deleted after. 573 576 addJob(job, position); 574 577 } 575 578 else { 576 System.err.println("I've already done this job twice. I refuse to requeue it again!!!");579 Gatherer.println("I've already done this job twice. I refuse to requeue it again!!!"); 577 580 } 578 581 } … … 681 684 // Check if the origin file exists. 682 685 if(!source.exists()) { 683 System.err.println("Couldn't find the source file.");686 Gatherer.println("Couldn't find the source file."); 684 687 throw(new FileNotFoundException()); 685 688 }
Note:
See TracChangeset
for help on using the changeset viewer.