// Get manifest by filename or given reader func (m *Model) GetManifest(name string, in io.Reader) (res *proto.Manifest, err error) { r, isManifest, err := proto.PeekManifest(in) if err != nil { return } if isManifest { // ok - just read res, err = proto.NewFromManifest(r) return } // Hard way. First - try git var sideR io.Reader if m.Git != nil { if sideR = m.getGitReader(name); sideR != nil { res, err = proto.NewFromAny(sideR, m.chunkSize) return } } // No git - make from blob res, err = proto.NewFromBLOB(r, m.chunkSize) return }
func (c *GitSmudgeCmd) Run(args ...string) (err error) { name := args[0] m, err := proto.NewFromAny(c.Stdin, c.ChunkSize) logx.Debugf("smudge manifest for %s (%s)", name, m.ID) err = m.Serialize(c.Stdout) return }
func NewShadowFromFile(filename string) (res *proto.Manifest, err error) { r, err := os.Open(filename) if err != nil { return } defer r.Close() res, err = proto.NewFromAny(r, proto.CHUNK_SIZE) return }
func (m *Model) getManifest(name string, blobs, manifests bool) (res *proto.Manifest, err error) { lock, err := m.FdLocks.Take() if err != nil { return } defer lock.Release() logx.Tracef("feeding manifest from %s", lists.OSFromSlash(lists.OSJoin(m.WD, name))) f, err := os.Open(lists.OSFromSlash(lists.OSJoin(m.WD, name))) if err != nil { logx.Errorf("!!! %s", err) return } defer f.Close() var r io.Reader var isManifest bool if r, isManifest, err = proto.PeekManifest(f); err != nil { return } if (isManifest && !manifests) || (!isManifest && !blobs) { return } if isManifest { res, err = proto.NewFromManifest(r) return } // Hard way. First - try git var sideR io.Reader if m.Git != nil { if sideR = m.getGitReader(name); sideR != nil { res, err = proto.NewFromAny(sideR, m.chunkSize) return } } // No git - make from blob res, err = proto.NewFromBLOB(r, m.chunkSize) return }