From ed3e18ef0c872d3b60378162cb68d5a765f704b0 Mon Sep 17 00:00:00 2001 From: Bartek Fabiszewski Date: Fri, 25 Aug 2017 13:07:34 +0200 Subject: [PATCH] Delete incomplete track in case of import error --- utils/import.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/import.php b/utils/import.php index 68dec28..15bd780 100755 --- a/utils/import.php +++ b/utils/import.php @@ -93,6 +93,7 @@ foreach ($gpx->trk as $trk) { uUtils::exitWithError($lang["servererror"]); break; } + $track = new uTrack($trackId); foreach($trk->trkseg as $segment) { foreach($segment->trkpt as $point) { @@ -110,10 +111,11 @@ foreach ($gpx->trk as $trk) { if (count($ext->accuracy)) { $accuracy = (int) $ext->accuracy; } if (count($ext->provider)) { $provider = (string) $ext->provider; } } - $ret = uPosition::add($user->id, $trackId, + $ret = $track->addPosition($auth->user->id, $time, (double) $point["lat"], (double) $point["lon"], $altitude, $speed, $bearing, $accuracy, $provider, NULL, NULL); if ($ret === false) { + $track->delete(); uUtils::exitWithError($lang["servererror"]); } }