MCPcopy
hub / github.com/perkeep/perkeep / RunCommand

Method RunCommand

cmd/pk-put/files.go:128–291  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

126}
127
128func (c *fileCmd) RunCommand(args []string) error {
129 if c.vivify {
130 if c.makePermanode || c.filePermanodes || c.tag != "" || c.title != "" {
131 return cmdmain.UsageError("--vivify excludes any other option")
132 }
133 }
134 if c.title != "" && !c.makePermanode {
135 return cmdmain.UsageError("Can't set title without using --permanode")
136 }
137 if c.tag != "" && !c.makePermanode && !c.filePermanodes {
138 return cmdmain.UsageError("Can't set tag without using --permanode or --filenodes")
139 }
140 if c.histo != "" && !c.memstats {
141 return cmdmain.UsageError("Can't use histo without memstats")
142 }
143 if c.deleteAfterUpload && !c.filePermanodes {
144 return cmdmain.UsageError("Can't set use --delete_after_upload without --filenodes")
145 }
146 if c.filePermanodes && c.contentsOnly {
147 return cmdmain.UsageError("--contents_only and --filenodes are exclusive. Use --permanode instead.")
148 }
149
150 up := getUploader()
151 if c.memstats {
152 sr := new(statspkg.Receiver)
153 up.altStatReceiver = sr
154 defer func() { DumpStats(sr, c.histo) }()
155 }
156 c.initCaches(up)
157
158 if c.makePermanode || c.filePermanodes {
159 testSigBlobRef := up.Client.SignerPublicKeyBlobref()
160 if !testSigBlobRef.Valid() {
161 return cmdmain.UsageError("A GPG key is needed to create permanodes; configure one or use vivify mode.")
162 }
163 }
164 up.fileOpts = &fileOptions{
165 permanode: c.filePermanodes,
166 tag: c.tag,
167 vivify: c.vivify,
168 exifTime: c.exifTime,
169 capCtime: c.capCtime,
170 contentsOnly: c.contentsOnly,
171 }
172
173 var (
174 permaNode *client.PutResult
175 lastPut *client.PutResult
176 err error
177 )
178 if c.makePermanode {
179 if len(args) != 1 {
180 return fmt.Errorf("The --permanode flag can only be used with exactly one file or directory argument")
181 }
182 permaNode, err = up.UploadNewPermanode(ctxbg)
183 if err != nil {
184 return fmt.Errorf("Uploading permanode: %v", err)
185 }

Callers

nothing calls this directly

Calls 15

initCachesMethod · 0.95
StartMethod · 0.95
WaitMethod · 0.95
UsageErrorTypeAlias · 0.92
PreExitFunction · 0.92
LogfFunction · 0.92
NewSetAttributeClaimFunction · 0.92
NewAddAttributeClaimFunction · 0.92
getUploaderFunction · 0.85
DumpStatsFunction · 0.85
handleResultFunction · 0.85

Tested by

no test coverage detected