4d519567736f

one comment style everywhere, a discard helper in settings, and lined-out struct literals (3.2.16)

time
2026-09-29 02:32 UTC · 2 weeks ago
machine
Junes-MacBook-Pro.local
agent
claude-sonnet-5-5
session
comment and tidy pass
parent
2213f5046815
9 files VERSION+1 −1src/exchange/exchange.v+2 −2src/exchange/source.v+7 −7src/koh3.v+1 −0src/machine/settings.v+12 −6src/remote/web.v+7 −3src/snapshot/ignore.v+2 −2src/storage/storage.v+2 −2v.mod+1 −1
VERSION+1 −1
@@ -1 +1 @@1-3.2.151+3.2.16

view file

src/exchange/exchange.v+2 −2
@@ -20,8 +20,8 @@2020 // Where the repo's name on the remote is remembered.2121 const repo_state_key = 'remote_repo'2222 23-// The remote head as of this machine's last successful offer, as the document24-// asks; nothing reads it back yet.23+// The remote head as of this machine's last successful offer: a record for the24+// person or a future feature. Nothing depends on it.2525 const remote_head_key = 'remote_head'2626 2727 pub const no_saves = 'this repo has no saves yet — nothing to offer'

view file

src/exchange/source.v+7 −7
@@ -12,30 +12,30 @@1212 1313 const source_key = 'source'1414 15-/// The address a stolen repo came from, `<base>/<repo>`, or '' for an ordinary repo.15+// The address a stolen repo came from, `<base>/<repo>`, or '' for an ordinary repo.1616 pub fn source_of(store &storage.Store) string {1717 	return store.state(source_key) or { '' }1818 }1919 20-/// The Kepr part of a source: what `koh remote <host>` would have to name.20+// The Kepr part of a source: what `koh remote <host>` would have to name.2121 pub fn source_host(source string) string {2222 	return source.all_before_last('/')2323 }2424 25-/// True when this machine was set up by `koh remote <host>` for the same host, so that host's26-/// addresses are this machine's own bucket (Part 2 of the addendum).25+// True when this machine was set up by `koh remote <host>` for the same host, so that host's26+// addresses are this machine's own bucket (Part 2 of the addendum).2727 pub fn signed_in_to(host string) bool {2828 	settings := machine.load_remote() or { return false }2929 	return settings.kind == machine.kind_s3 && settings.kepr != '' && settings.kepr == host3030 }3131 32-/// read_only opens the backend a stolen repo came from: public, and never written to.32+// read_only opens the backend a stolen repo came from: public, and never written to.3333 pub fn read_only(source string) !remote.Backend {3434 	return remote.new_web(source_host(source))!3535 }3636 37-/// remember_source and forget_source are the only two writes: a repo is either a stolen one or an38-/// ordinary one, never both.37+// remember_source and forget_source are the only two writes: a repo is either a stolen one or an38+// ordinary one, never both.3939 pub fn remember_source(store &storage.Store, source string) ! {4040 	store.set_state(source_key, source)!4141 }

view file

src/koh3.v+1 −0
@@ -1,3 +1,4 @@1+//! Program entry: hands the command line to the CLI and exits with its code.12 module main23 34 import os

view file

src/machine/settings.v+12 −6
@@ -95,34 +95,40 @@9595 		os.rm(temporary)!9696 	}9797 	mut file := os.open_file(temporary, 'w', 0o600) or {98-		os.rm(temporary) or {}98+		discard(temporary)9999 		return err100100 	}101101 	os.chmod(temporary, 0o600) or {102102 		file.close()103-		os.rm(temporary) or {}103+		discard(temporary)104104 		return err105105 	}106106 	file.write_string(text) or {107107 		file.close()108-		os.rm(temporary) or {}108+		discard(temporary)109109 		return err110110 	}111111 	file.close()112112 	// close() does not report a failed flush, so check what actually landed.113113 	if (os.read_file(temporary) or { '' }) != text {114-		os.rm(temporary) or {}114+		discard(temporary)115115 		return error('could not write ${path}')116116 	}117117 	// V's rename, like mv(1), would move the file INTO a directory there.118118 	if os.is_dir(path) {119-		os.rm(temporary) or {}119+		discard(temporary)120120 		return error('${path} is a directory')121121 	}122122 	os.rename(temporary, path) or {123-		os.rm(temporary) or {}123+		discard(temporary)124124 		return err125125 	}126+}127+128+// discard removes the half-written temporary. Its own failure is dropped: the129+// error that sent us here is the one worth reporting.130+fn discard(temporary string) {131+	os.rm(temporary) or {}126132 }127133 128134 pub fn load_credentials() !Credentials {

view file

src/remote/web.v+7 −3
@@ -13,8 +13,8 @@1313 	return Web{ base: kepr_host(base)! }1414 }1515 16-/// kepr_host normalises a Kepr address: https unless the scheme says otherwise, and scheme, host17-/// and port only. A path, a query, a fragment or credentials would send the code somewhere else.16+// kepr_host normalises a Kepr address: https unless the scheme says otherwise, and scheme, host17+// and port only. A path, a query, a fragment or credentials would send the code somewhere else.1818 pub fn kepr_host(value string) !string {1919 	for letter in value {2020 		if letter <= ` ` {@@ -55,7 +55,11 @@5555 	if response.status_code < 200 || response.status_code >= 300 {5656 		return error('web GET ${key} failed: ${response.status_code}')5757 	}58-	return Object{ found: true, body: response.body.bytes(), tag: response.header.get_custom('etag', http.HeaderQueryConfig{}) or { '' } }58+	return Object{59+		found: true60+		body:  response.body.bytes()61+		tag:   response.header.get_custom('etag', http.HeaderQueryConfig{}) or { '' }62+	}5963 }6064 6165 pub fn (mut w Web) list(prefix string) ![]string {

view file

src/snapshot/ignore.v+2 −2
@@ -81,8 +81,8 @@8181 	}8282 }8383 84-/// add_ignore appends an anchored `/<path>` rule to `.kohignore`, unless that line is already85-/// there, and reports whether it wrote one.84+// add_ignore appends an anchored `/<path>` rule to `.kohignore`, unless that line is already85+// there, and reports whether it wrote one.8686 pub fn add_ignore(root string, path string) !bool {8787 	file := os.join_path(root, ignore_file)8888 	text := if os.is_file(file) { os.read_file(file)! } else { '' }

view file

src/storage/storage.v+2 −2
@@ -177,8 +177,8 @@177177 	s.db.exec('ROLLBACK') or {}178178 }179179 180-/// stripped_paths are the paths a whole-history strip removed. A strip bans its path for good,181-/// so no walk of the tree may pick it up again.180+// stripped_paths are the paths a whole-history strip removed. A strip bans its path for good,181+// so no walk of the tree may pick it up again.182182 pub fn (s &Store) stripped_paths() ![]string {183183 	mut stmt := s.db.prepare("SELECT DISTINCT path FROM events WHERE kind = 'strip' AND IFNULL(save_id, '') = ''")!184184 	defer {

view file

v.mod+1 −1
@@ -1,6 +1,6 @@11 Module {22 	name: 'koh3'3-	version: '3.2.15'3+	version: '3.2.16'44 	description: 'One SQLite file per repo, one line of history.'55 	license: 'MIT'66 }

view file