Changeset 20578 for gsdl/trunk/perllib/inexport.pm
- Timestamp:
- 2009-09-10T10:51:48+12:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/perllib/inexport.pm
r19789 r20578 79 79 sub new_vs_old_import_diff 80 80 { 81 my ($archive_info,$block_hash,$importdir ) = @_;81 my ($archive_info,$block_hash,$importdir,$archivedir,$verbosity,$incremental_mode) = @_; 82 82 83 83 # First convert all files to absolute form … … 108 108 109 109 # entry in 'all_files' is moved to either 'existing_files', 110 # 'deleted_files', or 'new_files'110 # 'deleted_files', 'new_files', or 'new_metadata_files' 111 111 112 112 if (!&util::filename_is_absolute($curr_file)) { … … 129 129 # figure out if new file or not 130 130 if (defined $full_prev_all_files->{$full_curr_file}) { 131 132 if ($incremental_mode eq "all") { 133 134 # had it before 135 $block_hash->{'existing_files'}->{$full_curr_file} = 1; 136 137 # Now remove it, so by end of loop only the files 138 # that need deleting are left 131 139 132 # had it before 133 $block_hash->{'existing_files'}->{$full_curr_file} = 1; 134 135 # Now remove it, so by end of loop only the files 136 # that need deleting are left 137 138 delete $full_prev_all_files->{$full_curr_file}; 139 } 140 delete $full_prev_all_files->{$full_curr_file}; 141 } 142 else { 143 # Warning in "onlyadd" mode, but had it before! 144 print STDERR "Warning: File $full_curr_file previously imported.\n"; 145 print STDERR " Treating as new file\n"; 146 147 $block_hash->{'new_files'}->{$full_curr_file} = 1; 148 delete $full_prev_all_files->{$full_curr_file}; 149 } 150 } 140 151 else { 141 $block_hash->{'new_files'}->{$full_curr_file} = 1; 142 } 152 if ($block_hash->{'metadata_files'}->{$full_curr_file}) { 153 # the new file is the special sort of file greenstone uses 154 # to attach metadata to src documents 155 # i.e metadata.xml 156 # (but note, the filename used is not constrained in 157 # Greenstone to always be this) 158 159 ## print STDERR "***** Detected new metadata file: $full_curr_file\n"; 160 $block_hash->{'new_metadata_files'}->{$full_curr_file} = 1; 161 } 162 else { 163 $block_hash->{'new_files'}->{$full_curr_file} = 1; 164 } 165 } 166 143 167 144 168 delete $block_hash->{'all_files'}->{$curr_file}; 145 169 } 146 170 171 172 # Deal with complication of new metadata.xml files by forcing 173 # everything from this point down in the file hierarchy to 174 # be freshly imported. 175 # 176 # This may mean files that have not changed are reindexed, but does 177 # guarantee by the end of processing all new metadata is correctly 178 # associated with the relevant document(s). 179 180 foreach my $new_mdf (keys %{$block_hash->{'new_metadata_files'}}) { 181 my ($fileroot,$situated_dir,$ext) = fileparse($new_mdf, "\\.[^\\.]+\$"); 182 183 $situated_dir =~ s/[\\\/]+$//; # remove tailing slashes 184 185 # Go through existing_files, and mark anything that is contained 186 # within 'situated_dir' to be reindexed (in case some of the metadata 187 # attaches to one of these files) 188 189 my $reindex_files = []; 190 191 foreach my $existing_f (keys %{$block_hash->{'existing_files'}}) { 192 # need to protect windows slash \ in regular expression? 193 194 if ($existing_f =~ m/^$situated_dir/) { 195 push(@$reindex_files,$existing_f); 196 $block_hash->{'reindex_files'}->{$existing_f} = 1; 197 198 } 199 } 200 201 # Reindexing is accomplished by putting them in th list for reindexing (line above) 202 # and then tagging the arcinfo version as to be deleted. 203 204 _mark_docs_for_deletion($archive_info,$block_hash,$reindex_files,$archivedir,$verbosity, "reindex"); 205 206 # metadata file needs to be in new_files list so parsed by MetadataXMLPlug 207 # (or equivalent) 208 $block_hash->{'new_files'}->{$new_mdf} = 1; 209 210 } 211 212 147 213 # By this point full_prev_all_files contains the files 148 214 # mentioned in archiveinf-src.db but are not in the 'import' … … 153 219 # 154 220 # In building the final list of files to delete, we test to see if 155 # it exists on the filesystem and if it does (unusual for a file156 # that's allegedly deleted!), supress it from going into the final157 # list221 # it exists on the filesystem and if it does (unusual for a "normal" 222 # file in import, but possible in the case of 'tmp' files), 223 # supress it from going into the final list 158 224 159 225 my $collectdir = $ENV{'GSDLCOLLECTDIR'}; … … 174 240 } 175 241 } @deleted_files; 242 243 244 176 245 } 177 246
Note:
See TracChangeset
for help on using the changeset viewer.