• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

CLI interface to medialist (fossil mirror)


Commit MetaInfo

Revision3fb62f9551515dd48e211ddbeb3fb5bb36130198 (tree)
Time2023-02-11 13:46:12
Authormio <stigma@disr...>
Commitermio

Log Message

MediaList (library) v0.2.0

More of a fix where the ml_fetch_all function would call
std.string.strip on the mTSV line before splitting on a TAB, this
resulted in a RangeError being thrown if the number of "sections" didn't
match the number of "headers", even though they actually did in the .tsv
file.

NOTE: This still will through if there is a genuine mismatch between the number of headers or the number of fields in the file.

FossilOrigin-Name: 6a0938bdd1c5797799e3309637e6f7d61640b57a1f490a1e7291020bc0a98dfd

Change Summary

Incremental Difference

--- a/medialist.d
+++ b/medialist.d
@@ -1,5 +1,5 @@
11 /*
2- * Copyright (C) 2022 dawning.
2+ * Copyright (C) 2022, 2023 dawning.
33 *
44 * This file is part of medialist-cli.
55 *
@@ -28,6 +28,26 @@ import std.path;
2828 import std.stdio;
2929 import std.string;
3030
31+/**
32+ * Enumeration string containing the verison of MediaList.
33+ *
34+ * Since: 0.2.0
35+ */
36+enum string MediaListVersion = "0.2.0";
37+
38+/**
39+ * Enumeration array of int containing the version of MediaList.
40+ *
41+ * Version represents the Major.Minor.Patch.
42+ *
43+ * Major version changes represent the modification or removal of an existing
44+ * API. Patch versions represent compile-time fixes. Minor versions represent
45+ * all other changes.
46+ *
47+ * Since: 0.2.0
48+ */
49+enum int[3] MediaListVersionA = [0, 2, 0];
50+
3151 struct MediaList
3252 {
3353 immutable string filePath;
@@ -371,6 +391,7 @@ MediaListItem[] ml_fetch_all(MediaList* list, MLError* err = null)
371391
372392 File listFile = File(list.filePath);
373393 list.isOpen = true;
394+ scope(exit) list.isOpen = false;
374395
375396 string line;
376397 bool pastHeader = false;
@@ -421,15 +442,19 @@ MediaListItem[] ml_fetch_all(MediaList* list, MLError* err = null)
421442 continue;
422443 }
423444
424- string[] sections = line.strip().split("\t");
445+ // Separate the split and strip so we don't remove any
446+ // trailing \t which may be used as a placeholder.
447+ string[] sections = line.split("\t");
448+ sections[$ - 1] = sections[$ - 1].strip;
425449
426450 items ~= MediaListItem(sections[titleIndex],
427- sections[progressIndex], sections[statusIndex], sections[startIndex],
428- sections[endIndex], sections[lastIndex], true);
451+ sections[progressIndex],
452+ sections[statusIndex],
453+ sections[startIndex],
454+ sections[endIndex],
455+ sections[lastIndex], true);
429456 }
430457
431- list.isOpen = false;
432-
433458 return items;
434459 }
435460