~welt/murse

ref: v0.0.4 murse/files.go -rw-r--r-- 359 bytes
3391dfb8welt Fix file not being truncated 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package main

import (
	"os"
	"path/filepath"
	"strconv"
	"strings"
)

func getInstalledRevision(path string) (int, error) {
	rev := -1
	bytes, err := os.ReadFile(filepath.Join(filepath.FromSlash(path), ".revision"))
	if os.IsNotExist(err) {
		return rev, nil
	}
	if err != nil {
		return rev, err
	}

	return strconv.Atoi(strings.TrimSpace(string(bytes)))
}