|
@@ -67,15 +67,17 @@ get '/status' => sub {
|
|
|
return template 'error', $error;
|
|
|
}
|
|
|
|
|
|
+ my $lock_filename = "$cocktail_store/$opt_dossier/$opt_projet.lock";
|
|
|
+ my $pdf_filename = "$cocktail_store/$opt_dossier/$opt_projet.pdf";
|
|
|
+
|
|
|
my ($compilation_status, $compilation_text);
|
|
|
- if(-e "$cocktail_store/$opt_dossier/$opt_projet.lock") {
|
|
|
- $compilation_text = "En cours de compilation...";
|
|
|
+ if(-e $lock_filename) {
|
|
|
+ my $date_time = _get_datetime_for($lock_filename);
|
|
|
+ $compilation_text = "En cours de compilation depuis $date_time";
|
|
|
$compilation_status = 'IN PROGRESS';
|
|
|
}
|
|
|
- elsif(-e "$cocktail_store/$opt_dossier/$opt_projet.pdf") {
|
|
|
- my @stat = stat "$cocktail_store/$opt_dossier/$opt_projet.pdf";
|
|
|
- my $ctime = $stat[10];
|
|
|
- my $date_time = POSIX::strftime("%Y-%m-%d %H:%M:%S", localtime($ctime) );
|
|
|
+ elsif(-e $pdf_filename) {
|
|
|
+ my $date_time = _get_datetime_for($pdf_filename);
|
|
|
$compilation_text = $date_time;
|
|
|
$compilation_status = 'COMPLETED';
|
|
|
}
|
|
@@ -88,5 +90,15 @@ get '/status' => sub {
|
|
|
return to_json { text => $compilation_text, status => $compilation_status };
|
|
|
};
|
|
|
|
|
|
+sub _get_datetime_for {
|
|
|
+ my $filename = shift;
|
|
|
+ return unless -e $filename;
|
|
|
+
|
|
|
+ my @stat = stat $filename;
|
|
|
+ my $ctime = $stat[10];
|
|
|
+ my $date_time = POSIX::strftime("%Y-%m-%d %H:%M:%S", localtime($ctime) );
|
|
|
+ return $date_time;
|
|
|
+}
|
|
|
|
|
|
true;
|
|
|
+
|