Revision c5057972
Von Bernd Bleßmann vor mehr als 2 Jahren hinzugefügt
SL/File/Backend/Filesystem.pm | ||
---|---|---|
6 | 6 |
use SL::DB::File; |
7 | 7 |
use File::Copy; |
8 | 8 |
use File::Slurp; |
9 |
use File::stat; |
|
9 | 10 |
use File::Path qw(make_path); |
10 | 11 |
|
11 | 12 |
# |
... | ... | |
66 | 67 |
die 'dbfile not exists' unless $params{dbfile}; |
67 | 68 |
my $dbfile = $params{dbfile}; |
68 | 69 |
die 'no file contents' unless $params{file_path} || $params{file_contents}; |
70 |
|
|
71 |
# Do not save and do not create a new version of the document if file size of last version is the same. |
|
72 |
if ($dbfile->source eq 'created' && $self->get_version_count(dbfile => $dbfile)) { |
|
73 |
my $new_file_size = $params{file_path} ? stat($params{file_path})->size : length($params{file_contents}); |
|
74 |
my $last_file_size = stat($self->_filesystem_path($dbfile))->size; |
|
75 |
|
|
76 |
return 1 if $last_file_size == $new_file_size; |
|
77 |
} |
|
78 |
|
|
69 | 79 |
$dbfile->backend_data(0) unless $dbfile->backend_data; |
70 | 80 |
$dbfile->backend_data($dbfile->backend_data*1+1); |
71 | 81 |
$dbfile->save->load; |
... | ... | |
100 | 110 |
|
101 | 111 |
die "No file found at $path. Expected: $params{dbfile}{file_name}, file.id: $params{dbfile}{id}" if !-f $path; |
102 | 112 |
|
103 |
my @st = stat($path); |
|
104 |
my $dt = DateTime->from_epoch(epoch => $st[9], time_zone => $::locale->get_local_time_zone()->name, locale => $::lx_office_conf{system}->{language})->clone(); |
|
113 |
my $dt = DateTime->from_epoch(epoch => stat($path)->mtime, time_zone => $::locale->get_local_time_zone()->name, locale => $::lx_office_conf{system}->{language})->clone(); |
|
105 | 114 |
return $dt; |
106 | 115 |
} |
107 | 116 |
|
Auch abrufbar als: Unified diff
mini-DMS: Filesystem-Backend: ungeänderte Dokumente nicht doppelt speichern.
Einfacher Größenvergleich mit letzter Version.