Skip to content

Commit fd8d929

Browse files
author
Roman Lomonosov
committed
configurable tree date
1 parent 03cda0e commit fd8d929

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

uploader/index.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const ReverseLevelOffset = 10000
2020
const TreeLevelOffset = 20000
2121
const ReverseTreeLevelOffset = 30000
2222

23-
const TreeDate = 42 // 1970-02-12
23+
const DefaultTreeDate = 42 // 1970-02-12
2424

2525
func NewIndex(base *Base) *Index {
2626
u := &Index{}
@@ -46,6 +46,11 @@ func (u *Index) parseFile(filename string, out io.Writer) (map[string]bool, erro
4646
var level, index, l int
4747
var p []byte
4848

49+
treeDate := uint16(DefaultTreeDate)
50+
if !u.config.TreeDate.IsZero() {
51+
treeDate = RowBinary.TimestampToDays(uint32(u.config.TreeDate.Unix()))
52+
}
53+
4954
LineLoop:
5055
for {
5156
name, err := reader.ReadRecord()
@@ -89,7 +94,7 @@ LineLoop:
8994
wb.WriteUint32(version)
9095

9196
// Tree
92-
wb.WriteUint16(TreeDate)
97+
wb.WriteUint16(treeDate)
9398
wb.WriteUint32(uint32(level + TreeLevelOffset))
9499
wb.WriteBytes(name)
95100
wb.WriteUint32(version)
@@ -104,7 +109,7 @@ LineLoop:
104109

105110
newSeries[string(p[:index+1])] = true
106111

107-
wb.WriteUint16(TreeDate)
112+
wb.WriteUint16(treeDate)
108113
wb.WriteUint32(uint32(l + TreeLevelOffset))
109114
wb.WriteBytes(p[:index+1])
110115
wb.WriteUint32(version)
@@ -113,7 +118,7 @@ LineLoop:
113118
}
114119

115120
// Reverse path without date
116-
wb.WriteUint16(TreeDate)
121+
wb.WriteUint16(treeDate)
117122
wb.WriteUint32(uint32(level + ReverseTreeLevelOffset))
118123
wb.WriteBytes(reverseName)
119124
wb.WriteUint32(version)

0 commit comments

Comments
 (0)