X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/6969d5c2475912e927c868e56b153ecacdfb817e..d1f44c84d990f57982854c6a4716c0f233f45bca:/SL/File/Backend/Filesystem.pm?ds=sidebyside diff --git a/SL/File/Backend/Filesystem.pm b/SL/File/Backend/Filesystem.pm index 19d81e334..fe8604c0b 100644 --- a/SL/File/Backend/Filesystem.pm +++ b/SL/File/Backend/Filesystem.pm @@ -14,38 +14,34 @@ use File::Path qw(make_path); sub delete { my ($self, %params) = @_; - $main::lxdebug->message(LXDebug->DEBUG2(), "del in backend " . $self . " file " . $params{dbfile}); - $main::lxdebug->message(LXDebug->DEBUG2(), "file id=" . ($params{dbfile}->id * 1)); - die "no dbfile" unless $params{dbfile}; + die "no dbfile in backend delete" unless $params{dbfile}; my $backend_data = $params{dbfile}->backend_data; $backend_data = 0 if $params{last}; $backend_data = $params{dbfile}->backend_data-1 if $params{all_but_notlast}; if ($backend_data > 0 ) { - $main::lxdebug->message(LXDebug->DEBUG2(), "backend_data=" .$backend_data); for my $version ( 1..$backend_data) { my $file_path = $self->_filesystem_path($params{dbfile},$version); - $main::lxdebug->message(LXDebug->DEBUG2(), "unlink " .$file_path); unlink($file_path); } if ($params{all_but_notlast}) { my $from = $self->_filesystem_path($params{dbfile},$params{dbfile}->backend_data); - my $to = $self->_filesystem_path($params{dbfile},$params{dbfile}->backend_data); - die "file not exists" unless -f $from; + my $to = $self->_filesystem_path($params{dbfile},1); + die "file not exists in backend delete" unless -f $from; rename($from,$to); $params{dbfile}->backend_data(1); } else { $params{dbfile}->backend_data(0); my $dir_path = $self->_filesystem_path($params{dbfile}); rmdir($dir_path); - $main::lxdebug->message(LXDebug->DEBUG2(), "unlink " .$dir_path); } } else { my $file_path = $self->_filesystem_path($params{dbfile},$params{dbfile}->backend_data); - die "file not exists" unless -f $file_path; + die "file not exists in backend delete" unless -f $file_path; unlink($file_path); $params{dbfile}->backend_data($params{dbfile}->backend_data-1); } + return 1; } sub rename { @@ -81,14 +77,12 @@ sub get_version_count { 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} && ($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 get_mtime" if !-f $path; my @st = stat($path); my $dt = DateTime->from_epoch(epoch => $st[9])->clone(); - $main::lxdebug->message(LXDebug->DEBUG2(), "dt=" .$dt); return $dt; } @@ -96,7 +90,7 @@ sub get_filepath { my ($self, %params) = @_; die "no dbfile" unless $params{dbfile}; my $path = $self->_filesystem_path($params{dbfile},$params{version}); - die "no file" if !-f $path; + die "no file in backend get_filepath" if !-f $path; return $path; } @@ -109,9 +103,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; } @@ -123,13 +117,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); - $main::lxdebug->message(LXDebug->DEBUG2(), "file path=" .$path." id=" .$dbfile->id." version=".$version." basename=".$dbfile->id . '_' . $version); + my $path = File::Spec->catdir($::lx_office_conf{paths}->{document_path}, $::auth->client->{id}, $iddir, $dbfile->id); if (!-d $path) { File::Path::make_path($path, { chmod => 0770 }); }