[Opensim-dev] Recover Assets from cache?

Jeff Kelley opensim at pescadoo.net
Mon Aug 25 14:58:27 UTC 2014


At 9:38 AM -0700 24/8/14, Mister Blue wrote:

>Some creative programming could probably recover a lot of the data 
>from the asset
>cache. The items in the cache are serialized instances of AssetBase 
>which is the object

I don't know it I am a creative programmer but this Perl script will 
read the filenames in the asset cache, check each for presence in the 
database and emit a list of 'dump asset' commands to paste into the 
simulator's console.

You will have to replace my own non-standard routines
   SQLOpen (SL::SQL::Access ) and
   selectAsset (SL::SQL::Database )
using DBI.


#############################################################
#
# Check for the presence of cached assets in database
#
#############################################################

use strict;
use Term::ANSIColor;
use SL::SQL::Access;	# Custom package
use SL::SQL::Database;	# Custom package
use List::MoreUtils qw(uniq);

my $simhost = 'kaidan';	# Your simulator's host
my $dbhost  = 'kaidan';	# Your database's host
my $simuldir = 'opensim';	# Directory to your simulator on $simhost
my $database = 'robust';	# Your R.O.B.U.S.T. database's name

sub pname {
	my $name = shift;
	return '-- not found --' unless defined $name;
	return '(unnamed)'	if $name eq '';
	return $name;
}

#########################################
# Collect cached uuid's
#########################################

my $command = "ssh $simhost ls -1  $simuldir/assetcache/*/*";
print "$command\n";
my @ls = `$command`;
my @uuids;

for (@ls) {
	my @elem = split '/',$_;
	my $uuid = pop @elem;
	next if $uuid =~ m/j2kCache_/;
	push @uuids,$uuid;
}

@uuids = uniq  @uuids;
print scalar @uuids, " uuids found\n";

#########################################
# Check existenz in database
#########################################

SQLOpen $database, $dbhost;
my @missing;
my $TRACE = 0;	# Set this to 1 to see all assets

for (@uuids) {
	my $uuid = $_; chomp $uuid;
	my @query = selectAsset $uuid;
	my $name = $query[0]->{name};
	my $type = $query[0]->{assetType};
	my $exists = defined $name;

	if ($TRACE) {
		my $color = ($exists)? 'green' : 'red';
		print color $color;
		printf "%s %s [%02d] %s\n", ' 'x8,$uuid,$type,(pname $name);
		print color 'reset';
	}
	push @missing,$uuid unless $exists;
}

SQLClose;

print scalar @missing, " uuids missing\n";

#########################################
# Dump missings
#########################################

print "\nPaste the following commands into the simulator:\n\n";

for (@missing) {
	printf "dump asset $_\n";
}





Exemple output:

Amiral$ perl CheckCache.pl
ssh kaidan ls -1  opensim/assetcache/*/*
4591 uuids found
26 uuids missing

Paste the following commands into the simulator:

dump asset 00252fc8-dfcc-48f8-a0b9-85a36ad0aa3f
dump asset 19bd4a5f-d71c-4590-acf9-283e867dd639
dump asset 1de105c4-35f4-4512-914a-1a6db85e63f8
dump asset 1e366f8a-70d8-45bc-95b6-715290982b99
dump asset 225ae1e3-d45e-41f2-a750-efabb71ea6c6
dump asset 2ac3a066-0a39-4eea-abf8-8d8081d758b8
dump asset 52f2c38f-87ea-4474-b97f-7b00fc1977a2
dump asset 5402279c-0490-4b86-aad8-193ed700c6e9
dump asset 5abb4057-6954-4b81-b95d-c2798fa6d61d
dump asset 5c2145b9-2f39-4d45-8f79-221d07bbeefc
dump asset 5e735e87-d556-4193-b11c-67ffa74fbde0
dump asset 6c93cc3d-9a40-4871-b63a-29f34e061c9b
dump asset 781408cf-8489-4138-89b7-8c81a5427bc0
dump asset 7c06e55c-8772-46c3-a4d0-303396f7adcc
dump asset 904ac745-b4da-4e82-8297-57730e0caa8b
dump asset 9250a132-bbdb-4d59-9b77-c38fb5d4abab
dump asset 9497c287-492f-4a62-8949-a15a208ab3cd
dump asset b6428052-a6bb-4e6a-9800-538581aa46f4
dump asset be7c31d0-81f9-4098-a33b-c762931008a4
dump asset c3b34a97-f4a5-48b3-a696-a7873d861a40
dump asset cd617890-d0fd-4417-9b16-7ca132e1d2ba
dump asset cd8a6dfa-7652-4a0e-9c5f-838ee93d208b
dump asset e640b28f-2424-463d-b168-fb875dc83e7e
dump asset f2f7323d-68d0-42b9-86ff-3c5b2f4a0111
dump asset f86a4389-0a90-4c97-8a76-151c164a70a0
dump asset fd408d59-cf94-4a26-850b-4d091431bc42


-- Jeff


More information about the Opensim-dev mailing list