Revision f8138d17
Von Moritz Bunkus vor mehr als 15 Jahren hinzugefügt
SL/DATEV.pm | ||
---|---|---|
30 | 30 |
use SL::DATEV::KNEFile; |
31 | 31 |
|
32 | 32 |
use Data::Dumper; |
33 |
use File::Path; |
|
34 |
use Time::HiRes qw(gettimeofday); |
|
35 |
|
|
36 |
sub _get_export_path { |
|
37 |
$main::lxdebug->enter_sub(); |
|
38 |
|
|
39 |
my ($a, $b) = gettimeofday(); |
|
40 |
my $path = get_path_for_download_token("${a}-${b}-${$}"); |
|
41 |
|
|
42 |
mkpath($path) unless (-d $path); |
|
43 |
|
|
44 |
$main::lxdebug->leave_sub(); |
|
45 |
|
|
46 |
return $path; |
|
47 |
} |
|
48 |
|
|
49 |
sub get_path_for_download_token { |
|
50 |
$main::lxdebug->enter_sub(); |
|
51 |
|
|
52 |
my $token = shift; |
|
53 |
my $path; |
|
54 |
|
|
55 |
if ($token =~ m|^(\d+)-(\d+)-(\d+)$|) { |
|
56 |
$path = "${main::userspath}/datev-export-${1}-${2}-${3}"; |
|
57 |
} |
|
58 |
|
|
59 |
$main::lxdebug->leave_sub(); |
|
60 |
|
|
61 |
return $path; |
|
62 |
} |
|
63 |
|
|
64 |
sub get_download_token_for_path { |
|
65 |
$main::lxdebug->enter_sub(); |
|
66 |
|
|
67 |
my $path = shift; |
|
68 |
my $token; |
|
69 |
|
|
70 |
if ($path =~ m|.*datev-export-(\d+)-(\d+)-(\d+)/?$|) { |
|
71 |
$token = "${1}-${2}-${3}"; |
|
72 |
} |
|
73 |
|
|
74 |
$main::lxdebug->leave_sub(); |
|
75 |
|
|
76 |
return $token; |
|
77 |
} |
|
78 |
|
|
79 |
sub clean_temporary_directories { |
|
80 |
$main::lxdebug->enter_sub(); |
|
81 |
|
|
82 |
foreach my $path (glob "${main::userspath}/datev-export-*") { |
|
83 |
next unless (-d $path); |
|
84 |
|
|
85 |
my $mtime = (stat($path))[9]; |
|
86 |
next if ((time() - $mtime) < 8 * 60 * 60); |
|
87 |
|
|
88 |
rmtree $path; |
|
89 |
} |
|
90 |
|
|
91 |
$main::lxdebug->leave_sub(); |
|
92 |
} |
|
33 | 93 |
|
34 | 94 |
sub _fill { |
35 | 95 |
$main::lxdebug->enter_sub(); |
... | ... | |
109 | 169 |
$main::lxdebug->enter_sub(); |
110 | 170 |
|
111 | 171 |
my ($self, $myconfig, $form) = @_; |
112 |
my @rc;
|
|
172 |
my $result;
|
|
113 | 173 |
|
114 | 174 |
if ($form->{exporttype} == 0) { |
115 |
@rc = &kne_buchungsexport($myconfig, $form);
|
|
175 |
$result = kne_buchungsexport($myconfig, $form);
|
|
116 | 176 |
} else { |
117 |
@rc = &kne_stammdatenexport($myconfig, $form);
|
|
177 |
$result = kne_stammdatenexport($myconfig, $form);
|
|
118 | 178 |
} |
119 | 179 |
|
120 | 180 |
$main::lxdebug->leave_sub(); |
121 | 181 |
|
122 |
return @rc;
|
|
182 |
return $result;
|
|
123 | 183 |
} |
124 | 184 |
|
125 | 185 |
sub obe_export { |
... | ... | |
560 | 620 |
|
561 | 621 |
my @filenames; |
562 | 622 |
|
563 |
my $export_path = $main::userspath . "/";
|
|
623 |
my $export_path = _get_export_path() . "/";
|
|
564 | 624 |
my $filename = "ED00000"; |
565 | 625 |
my $evfile = "EV01"; |
566 | 626 |
my @ed_versionsets; |
... | ... | |
724 | 784 |
### |
725 | 785 |
$main::lxdebug->leave_sub(); |
726 | 786 |
|
727 |
return @filenames;
|
|
787 |
return { 'download_token' => get_download_token_for_path($export_path), 'filenames' => \@filenames };
|
|
728 | 788 |
} |
729 | 789 |
|
730 | 790 |
sub kne_stammdatenexport { |
... | ... | |
741 | 801 |
|
742 | 802 |
my @filenames; |
743 | 803 |
|
744 |
my $export_path = $main::userspath . "/";
|
|
804 |
my $export_path = _get_export_path() . "/";
|
|
745 | 805 |
my $filename = "ED00000"; |
746 | 806 |
my $evfile = "EV01"; |
747 | 807 |
my @ed_versionsets; |
... | ... | |
839 | 899 |
|
840 | 900 |
$main::lxdebug->leave_sub(); |
841 | 901 |
|
842 |
return @filenames;
|
|
902 |
return { 'download_token' => get_download_token_for_path($export_path), 'filenames' => \@filenames };
|
|
843 | 903 |
} |
844 | 904 |
|
845 | 905 |
1; |
Auch abrufbar als: Unified diff
Jeden DATEV-Export in ein eigenes, eindeutig benanntes Verzeichnis schreiben, damit sich DATEV-Exporte nicht gegenseitig überschreiben.
Temporäre Verzeichnisse werden beim nächsten Aufruf gelöscht, sofern sie älter als acht Stunden sind.
Fix für Bug 924.