add filekey to owned files to allow us to distinguish between files
authorTony Cook <tony@develop-help.com>
Fri, 6 Nov 2009 00:30:27 +0000 (00:30 +0000)
committertony <tony@45cb6cf1-00bc-42d2-bb5a-07f51df49f94>
Fri, 6 Nov 2009 00:30:27 +0000 (00:30 +0000)
with the same name but different content

add an admin menu link to the task list

schema/bse.sql
site/cgi-bin/modules/BSE/API.pm
site/cgi-bin/modules/BSE/TB/OwnedFile.pm
site/templates/admin/back/list.tmpl
site/util/mysql.str

index 12fbabffb29d25db00e98674517351d6c04067df..9a7b2fdcaf843e3f111105d66cc02436433369ce 100644 (file)
@@ -896,6 +896,7 @@ create table bse_owned_files (
   body text not null,
   modwhen datetime not null,
   size_in_bytes integer not null,
+  filekey varchar(80) not null default '',
   index by_owner_category(owner_type, owner_id, category)
 );
 
index 2e82f15e8f99becd8fc9ac32de4f00e2e12ebf1b..4ce4abb7df0bff7cd928be9ccbb09f7e5f3cd96a 100644 (file)
@@ -323,6 +323,16 @@ sub bse_add_owned_file {
   $opts{owner_id} = $owner->id;
   $opts{category} ||= '';
   $opts{filename} = $saved_name;
+  unless ($opts{filekey}) {
+    my $fh = IO::File->new("$file_dir/$saved_name", "r");
+    if ($fh) {
+      require Digest::MD5;
+      my $md5 = Digest::MD5->new;
+      $md5->addfile($fh);
+
+      $opts{filekey} = $md5->hexdigest;
+    }
+  }
   
   require BSE::TB::OwnedFiles;
   my $result = BSE::TB::OwnedFiles->make(%opts);
index c1105d9485e916380f23cac2b3bdac90dfec43f1..ecdf319b6e6dc54284b2e8272d5fbb4e6102486d 100644 (file)
@@ -5,7 +5,7 @@ use BSE::Util::SQL qw(now_sqldatetime);
 use Carp qw(confess);
 
 sub columns {
-  return qw/id owner_type owner_id category filename display_name content_type download title body modwhen size_in_bytes/;
+  return qw/id owner_type owner_id category filename display_name content_type download title body modwhen size_in_bytes filekey/;
 }
 
 sub table {
index b760e3647c251cf23315c3c039fb877d0acb7159..472fb15e2733eb6409f9964f82ec2831772b792b 100644 (file)
@@ -1,5 +1,6 @@
 <:wrap admin/xbase.tmpl title=>"Background tasks", showtitle => 1 :>
 <:ifMessage:><p><:message:></p><:or:><:eif:>
+<p>| <a href="/cgi-bin/admin/menu.pl">Admin Menu</a> |</p>
 <table class="editform" id="backtasklist">
 <tr>
   <th>Task</th>
index 78d53069284165b37430ee3386dfd4dc826b2217..3f36bc29e225246819a358aa456c1450cba233ad 100644 (file)
@@ -194,6 +194,7 @@ Column title;varchar(255);NO;NULL;
 Column body;text;NO;NULL;
 Column modwhen;datetime;NO;NULL;
 Column size_in_bytes;int(11);NO;NULL;
+Column filekey;varchar(80);NO;;
 Index PRIMARY;1;[id]
 Index by_owner_category;0;[owner_type;owner_id;category]
 Table bse_product_option_values