aboutsummaryrefslogtreecommitdiffstats
path: root/src/i_insert.go
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-04-09 20:20:20 +0200
committerJoe <rbo@gmx.us>2024-04-09 20:20:20 +0200
commit44591cf0833423b8e1dcf1b11119364a5b0a7bf5 (patch)
tree8eae27ee8ef0b89803eb8151316f36f2f7ce39d5 /src/i_insert.go
parentcursor fucked up but ye (diff)
downloadhardflip-44591cf0833423b8e1dcf1b11119364a5b0a7bf5.tar.gz
hardflip-44591cf0833423b8e1dcf1b11119364a5b0a7bf5.tar.bz2
hardflip-44591cf0833423b8e1dcf1b11119364a5b0a7bf5.tar.xz
hardflip-44591cf0833423b8e1dcf1b11119364a5b0a7bf5.tar.zst
hardflip-44591cf0833423b8e1dcf1b11119364a5b0a7bf5.zip
qwe
Diffstat (limited to '')
-rw-r--r--src/i_insert.go20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/i_insert.go b/src/i_insert.go
index 5028c49..fd9b852 100644
--- a/src/i_insert.go
+++ b/src/i_insert.go
@@ -43,7 +43,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/i_insert.go
- * Tue Apr 09 15:36:02 2024
+ * Tue Apr 09 16:00:41 2024
* Joe
*
* insert a new host
@@ -73,10 +73,13 @@ func i_insert_format_filename(name, path string) string {
replace := "_"
str = re.ReplaceAllString(str, replace)
_, err := os.Stat(path + str + ".yml")
- for err == nil {
+ base := str
+ i := 0
+ for err == nil && i < 10000 {
uid := uuid.NewUUID()
- str += "_" + string(uid[0:4])
+ str = base + "_" + string(uid[0:4])
_, err = os.Stat(path + str + ".yml")
+ i++
}
str = strings.ToLower(str) + ".yml"
return str
@@ -99,14 +102,23 @@ func i_insert_host(data *HardData, insert *HostNode) {
data.insert = nil
return
}
+ // HACK: not sure if this is necessary
+ // if data.litems.curr.is_dir() == true {
+ // data.litems.curr.Dirs.lhost.add_back(insert)
+ // } else {
+ // tmp_next := data.litems.curr.Host.next
+ // data.litems.curr.Host.next = insert
+ // data.litems.curr.Host.next.next = tmp_next
+ // }
item := &ItemsNode{
- data.litems.curr.ID + 1,
+ 0,
nil,
insert,
data.litems.curr,
data.litems.curr.next,
}
data.litems.curr.next = item
+ data.litems.curr.next.next.prev = item
data.litems.reset_id()
data.litems.curr = data.litems.curr.next
data.ui.mode = NORMAL_MODE