non-port cache fix

Here is the diff for fixing caching problems for GIDs, UIDs, etc:

===================================================================
RCS file: /home/repositories/freshports-1/scripts/caching.pm,v
retrieving revision 1.3
diff -r1.3 caching.pm
54a55,75
> sub RemoveFileFromCache($;$) {
> 	my $this      = shift;
> 	my $file_name = shift;
> 
> 	my $CachingFile = $FreshPorts::Config::CachingRoot . '/cache/ports/' . $file_name . '.*.html';
> 	
> 	print "checking cache for '$CachingFile'\n";
> 	my @CacheEntries = glob($CachingFile);
> 	if (scalar @CacheEntries) {
> 		print "cache items exists.  removing them\n";
> 		
> 		foreach my $file (@CacheEntries) {
> 			if (!unlink($file)) {
> 				print "!!!unable to delete $file\n";
> 			}
> 		}
> 	} else {
> 		print "nothing in the cache to remove\n"
> 	}
> }
> 
65d85
< 	my $port;
79c99,127
< 		print "This commit had nothing that needs to be removed from the cache\n";
---
> 		print "This commit had no ports that need to be removed from the cache\n";
> 	}
> 
> 	return $ErrorFound;
> }
> 
> sub RemoveFilesFromCache($) {
> 	my $this = shift;
> 	#
> 	# given the files touched by this commit
> 	# remove each one from the cache
> 	#
> 
> 	my $FilesRef	= shift;
> 	my %Files		= %{$FilesRef};
> 
> 	my $error;
> 	my $ErrorFound = 0;
> 
> 	if (scalar %Files) {
> 		print "# # # # Removing files from the cache # # # #\n\n";
> 		while (my ($candidate, ) = each %Files) {
> 			print "$candidate\n";
> 
> 			$this->RemoveFileFromCache($candidate);
> 		}
> 		print "\n# # # # Finished: Removing files from the cache # # # #\n\n";
> 	} else {
> 		print "This commit had no files that need to be removed from the cache\n";
Index: observer_commits.pm
===================================================================
RCS file: /home/repositories/freshports-1/scripts/observer_commits.pm,v
retrieving revision 1.4
diff -r1.4 observer_commits.pm
14a15
> my %FilesCacheRemove;
86c87
< 		print "Observer will clear the following items from cache after the commit:\n";
---
> 		print "Observer will clear the following ports from cache after the commit:\n";
97a99,110
> 
> 		print "Observer will clear the following files from cache after the commit:\n";
> 		my @Files = @{$params{Files}};
> 		foreach $value (@Files) {
> 			my ($action, $filename, $revision, $commit_log_element_id, $element_id) = @$value;
> 			my ($subtree, $category_name, $port_name, $extra) = split/\//,$filename, 4;
> 			# look for special files outside a port, such as LEGAL, GIDs, UIDs
> 			if ($subtree eq $FreshPorts::Config::ports_prefix && defined($category_name) && !defined($port_name)) {
> 				$FilesCacheRemove{"$category_name"}	= "$category_name";
> 				print "$category_name\n";
> 			}
> 		}
106a120
> 		$Caching->RemoveFilesFromCache(\%FilesCacheRemove);
Index: xml_munge.pm
===================================================================
RCS file: /home/repositories/freshports-1/scripts/xml_munge.pm,v
retrieving revision 1.8
diff -r1.8 xml_munge.pm
389c389
< 			(message_id => $Updates{MessageId}, CommitLogPorts => \%CommitLogPorts) );
---
> 			(message_id => $Updates{MessageId}, CommitLogPorts => \%CommitLogPorts, Files => \@Files));

Leave a Reply

Scroll to Top