]> wagnertech.de Git - kivitendo-erp.git/blobdiff - SL/File/Backend/Filesystem.pm
classification_filter ist nicht mehr für Partpicker notwendig
[kivitendo-erp.git] / SL / File / Backend / Filesystem.pm
index a706c38202ac615d5a5e07931b594ba641cbfd86..72e8f306350d9b2d36536322c33a1fed089e8cc8 100644 (file)
@@ -54,8 +54,6 @@ sub rename {
 sub save {
   my ($self, %params) = @_;
   die 'dbfile not exists' unless $params{dbfile};
-  $main::lxdebug->message(LXDebug->DEBUG2(), "in backend " . $self . "  file " . $params{dbfile});
-  $main::lxdebug->message(LXDebug->DEBUG2(), "file id=" . $params{dbfile}->id . " path=" . $params{file_path});
   my $dbfile = $params{dbfile};
   die 'no file contents' unless $params{file_path} || $params{file_contents};
   $dbfile->backend_data(0) unless $dbfile->backend_data;
@@ -63,7 +61,6 @@ sub save {
   $dbfile->save->load;
 
   my $tofile = $self->_filesystem_path($dbfile);
-  $main::lxdebug->message(LXDebug->DEBUG2(), "topath=" . $tofile . " from=" . $params{file_path});
   if ($params{file_path} && -f $params{file_path}) {
     File::Copy::copy($params{file_path}, $tofile);
   }
@@ -85,10 +82,10 @@ sub get_mtime {
   my ($self, %params) = @_;
   die "no dbfile" unless $params{dbfile};
   $main::lxdebug->message(LXDebug->DEBUG2(), "version=" .$params{version});
-  die "unknown version" if $params{version} && 
+  die "unknown version" if $params{version} &&
                           ($params{version} < 0 || $params{version} > $params{dbfile}->backend_data) ;
   my $path = $self->_filesystem_path($params{dbfile},$params{version});
-  die "no file found in backend" if !-f $path;
+  die "no file found in backend or configuration to filesystem is wrong" if !-f $path;
   my @st = stat($path);
   my $dt = DateTime->from_epoch(epoch => $st[9])->clone();
   $main::lxdebug->message(LXDebug->DEBUG2(), "dt=" .$dt);
@@ -112,9 +109,9 @@ sub get_content {
 }
 
 sub enabled {
-  return 0 unless $::instance_conf->get_doc_files || $::instance_conf->get_doc_files_rootpath;
-  $main::lxdebug->message(LXDebug->DEBUG2(), "root path=" . $::instance_conf->get_doc_files_rootpath . " isdir=" .( -d $::instance_conf->get_doc_files_rootpath?"YES":"NO"));
-  return 0 unless -d $::instance_conf->get_doc_files_rootpath;
+  return 0 unless $::instance_conf->get_doc_files;
+  return 0 unless $::lx_office_conf{paths}->{document_path};
+  return 0 unless -d $::lx_office_conf{paths}->{document_path};
   return 1;
 }
 
@@ -126,12 +123,12 @@ sub enabled {
 sub _filesystem_path {
   my ($self, $dbfile, $version) = @_;
 
-  die "No files backend enabled" unless $::instance_conf->get_doc_files || $::instance_conf->get_doc_files_rootpath;
+  die "No files backend enabled" unless $::instance_conf->get_doc_files || $::lx_office_conf{paths}->{document_path};
 
   # use filesystem with depth 3
   $version    = $dbfile->backend_data if !$version || $version < 1 || $version > $dbfile->backend_data;
   my $iddir   = sprintf("%04d", $dbfile->id % 1000);
-  my $path    = File::Spec->catdir($::instance_conf->get_doc_files_rootpath, $iddir, $dbfile->id);
+  my $path    = File::Spec->catdir($::lx_office_conf{paths}->{document_path}, $::auth->client->{id}, $iddir, $dbfile->id);
   $main::lxdebug->message(LXDebug->DEBUG2(), "file path=" .$path." id=" .$dbfile->id." version=".$version." basename=".$dbfile->id . '_' . $version);
   if (!-d $path) {
     File::Path::make_path($path, { chmod => 0770 });
@@ -181,5 +178,3 @@ L<SL::File::Backend>
 Martin Helmling E<lt>martin.helmling@opendynamic.deE<gt>
 
 =cut
-
-