- Fix sorting by modification time to handle files changed at the same time

- Catch exceptions for logging
This commit is contained in:
Nathan Gray 2012-02-14 18:36:15 +00:00
parent f175a12c6e
commit 68798a2200
3 changed files with 16 additions and 7 deletions

View File

@ -131,6 +131,7 @@ abstract class importexport_basic_import_csv implements importexport_iface_impor
$this->results = array(); $this->results = array();
// Failures // Failures
$this->warnings = array();
$this->errors = array(); $this->errors = array();
while ( $record = $import_csv->get_record() ) { while ( $record = $import_csv->get_record() ) {

View File

@ -372,7 +372,7 @@ class importexport_import_csv implements importexport_iface_import_record { //,
// Need to handle format first // Need to handle format first
if($format == 1) if($format == 1)
{ {
$formatted = egw_time::createFromFormat(egw_time::$user_dateformat, $record[$name]); $formatted = egw_time::createFromFormat('!'.egw_time::$user_dateformat, $record[$name]);
if($formatted && $errors = egw_time::getLastErrors() && $errors['error_count'] == 0) if($formatted && $errors = egw_time::getLastErrors() && $errors['error_count'] == 0)
{ {
$record[$name] = $formatted->getTimestamp(); $record[$name] = $formatted->getTimestamp();

View File

@ -422,7 +422,7 @@
unset($targets[$key]); unset($targets[$key]);
continue; continue;
} }
$files[$mod_time] = $target; $files[$mod_time.$target] = $target;
} }
if($files) if($files)
{ {
@ -438,13 +438,21 @@
foreach($targets as $target) foreach($targets as $target)
{ {
if($resource = @fopen( $target, $data['type'] == 'import' ? 'rb' : 'wb' )) { $resource = null;
$result = $po->$type( $resource, $definition ); try {
if($resource = @fopen( $target, $data['type'] == 'import' ? 'rb' : 'wb' )) {
$result = $po->$type( $resource, $definition );
fclose($resource);
} else {
fwrite(STDERR,'importexport_schedule: ' . date('c') . ": File $target not readable! \n");
$data['errors'][$target][] = lang('%1 is not readable',$target);
}
}
catch (Exception $i_ex)
{
fclose($resource); fclose($resource);
} else { $data['errors'][$target][] = $i_ex->getMessage();
fwrite(STDERR,'importexport_schedule: ' . date('c') . ": File $target not readable! \n");
$data['errors'][$target][] = lang('%1 is not readable',$target);
} }