Commit cb49c83d authored by Meg Ford's avatar Meg Ford

Improve filename assignment

Parse the names of the existing filenames, and add one if there
is a name with a > number. Else get the number from 0 + 1.
parent b61364e3
...@@ -106,6 +106,13 @@ const Listview = new Lang.Class({ ...@@ -106,6 +106,13 @@ const Listview = new Lang.Class({
files.forEach(Lang.bind(this, files.forEach(Lang.bind(this,
function(file) { function(file) {
let returnedName = file.get_attribute_as_string("standard::display-name"); let returnedName = file.get_attribute_as_string("standard::display-name");
try {
let returnedNumber = parseInt(returnedName.split(" ")[1]);
if (returnedNumber > trackNumber)
trackNumber = returnedNumber;
} catch (e if e instanceof TypeError) {
// Don't handle the error
}
let finalFileName = GLib.build_filenamev([this._saveDir.get_path(), let finalFileName = GLib.build_filenamev([this._saveDir.get_path(),
returnedName]); returnedName]);
let fileUri = GLib.filename_to_uri(finalFileName, null); let fileUri = GLib.filename_to_uri(finalFileName, null);
......
...@@ -311,7 +311,7 @@ const BuildFileName = new Lang.Class({ ...@@ -311,7 +311,7 @@ const BuildFileName = new Lang.Class({
let fileExtensionName = MainWindow.audioProfile.fileExtensionReturner(); let fileExtensionName = MainWindow.audioProfile.fileExtensionReturner();
let dir = Gio.Application.get_default().saveDir; let dir = Gio.Application.get_default().saveDir;
this.dateTime = GLib.DateTime.new_now_local(); this.dateTime = GLib.DateTime.new_now_local();
this.clipNumber = Listview.allFilesInfo.length + 1; this.clipNumber = Listview.trackNumber + 1;
this.clipNumberString = this.clipNumber.toString(); this.clipNumberString = this.clipNumber.toString();
/* Translators: ""Clip %d"" is the default name assigned to a file created /* Translators: ""Clip %d"" is the default name assigned to a file created
by the application (for example, "Clip 1"). */ by the application (for example, "Clip 1"). */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment