diff --git a/apps/recorder/ChangeLog b/apps/recorder/ChangeLog index 94e2f28c22..cdb7352f36 100644 --- a/apps/recorder/ChangeLog +++ b/apps/recorder/ChangeLog @@ -32,4 +32,5 @@ 0.24: Can now specify `setRecording(true, {force:...` to not show a menu 0.25: Widget now has `isRecording()` for retrieving recording status. 0.26: Now record filename based on date -0.27: Fix first ever recorded filename being log0 (now all are dated) \ No newline at end of file +0.27: Fix first ever recorded filename being log0 (now all are dated) +0.28: Automatically create new track if the filename is different \ No newline at end of file diff --git a/apps/recorder/metadata.json b/apps/recorder/metadata.json index beb5648c8d..2f682016f9 100644 --- a/apps/recorder/metadata.json +++ b/apps/recorder/metadata.json @@ -2,7 +2,7 @@ "id": "recorder", "name": "Recorder", "shortName": "Recorder", - "version": "0.27", + "version": "0.28", "description": "Record GPS position, heart rate and more in the background, then download to your PC.", "icon": "app.png", "tags": "tool,outdoors,gps,widget", diff --git a/apps/recorder/widget.js b/apps/recorder/widget.js index 3c9afcf70e..e34fecfbca 100644 --- a/apps/recorder/widget.js +++ b/apps/recorder/widget.js @@ -241,9 +241,12 @@ options = options||{}; if (isOn && !settings.recording) { var date=(new Date()).toISOString().substr(0,10).replace(/-/g,""), trackNo=10; - if (!settings.file) { // if no filename set - settings.file = "recorder.log" + date + trackNo.toString(36) + ".csv"; - } else if (require("Storage").list(settings.file).length){ // if file exists + function getTrackFilename() { return "recorder.log" + date + trackNo.toString(36) + ".csv"; } + if (!settings.file || !settings.file.startsWith("recorder.log" + date)) { + // if no filename set or date different, set up a new filename + settings.file = getTrackFilename(); + } + if (require("Storage").list(settings.file).length){ // if file exists if (!options.force) { // if not forced, ask the question g.reset(); // work around bug in 2v17 and earlier where bg color wasn't reset return E.showPrompt( @@ -266,7 +269,7 @@ // new file - use the current date var newFileName; do { // while a file exists, add one to the letter after the date - newFileName = "recorder.log" + date + trackNo.toString(36) + ".csv"; + newFileName = getTrackFilename(); trackNo++; } while (require("Storage").list(newFileName).length); settings.file = newFileName;