added 'k' prefix to all directory blocks and 'h' prefix to all hash-cache blocks

This commit is contained in:
Jarek Kowalski committed 2018-06-06 21:15:52 -07:00
1 parent 985980925f
commit 8d751cb7bf
3 files changed
+7 -1

No files matched your search

+1
View File
@@ -57,6 +57,7 @@ func (om *Manager) NewWriter(ctx context.Context, opt WriterOptions) Writer {
repo: om,
splitter: om.newSplitter(),
description: opt.Description,
prefix: opt.Prefix,
}
if opt.splitter != nil {
+4 -1
View File
@@ -48,6 +48,7 @@ type objectWriter struct {
ctx context.Context
repo *Manager
prefix string
buffer bytes.Buffer
totalLength int64
@@ -97,7 +98,7 @@ func (w *objectWriter) flushBuffer() error {
w.buffer.Reset()
do := func() {
blockID, err := w.repo.blockMgr.WriteBlock(w.ctx, b2.Bytes(), "")
blockID, err := w.repo.blockMgr.WriteBlock(w.ctx, b2.Bytes(), w.prefix)
w.repo.trace("OBJECT_WRITER(%q) stored %v (%v bytes)", w.description, blockID, length)
if err != nil {
w.err.add(fmt.Errorf("error when flushing chunk %d of %s: %v", chunkID, w.description, err))
@@ -149,6 +150,7 @@ func (w *objectWriter) Result() (ID, error) {
repo: w.repo,
description: "LIST(" + w.description + ")",
splitter: w.repo.newSplitter(),
prefix: w.prefix,
}
jw := jsonstream.NewWriter(iw, indirectStreamType)
@@ -170,6 +172,7 @@ func (w *objectWriter) Result() (ID, error) {
// WriterOptions can be passed to Repository.NewWriter()
type WriterOptions struct {
Description string
Prefix string // empty string or a single-character ('g'..'z')
splitter objectSplitter
}
+2
View File
@@ -245,6 +245,7 @@ func (u *Uploader) uploadFile(ctx context.Context, file fs.File) (*dir.Entry, er
func (u *Uploader) uploadDir(ctx context.Context, rootDir fs.Directory) (*dir.Entry, object.ID, error) {
mw := u.repo.Objects.NewWriter(ctx, object.WriterOptions{
Description: "HASHCACHE:" + rootDir.Metadata().Name,
Prefix: "h",
})
defer mw.Close() //nolint:errcheck
u.cacheWriter = hashcache.NewWriter(mw)
@@ -552,6 +553,7 @@ func uploadDirInternal(
writer := u.repo.Objects.NewWriter(ctx, object.WriterOptions{
Description: "DIR:" + dirRelativePath,
Prefix: "k",
})
dw := dir.NewWriter(writer)