MCPcopy Create free account
hub / github.com/bcspragu/logseq-sync / BatchFileMeta

Method BatchFileMeta

db/sqlite/sqlite.go:202–215  ·  view source on GitHub ↗

Because the Logseq client can/will request files it hasn't uploaded yet, the map will contain nil entries for requested files that don't exist

(ctx context.Context, id db.GraphID, fIDs []db.FileID)

Source from the content-addressed store, hash-verified

200// Because the Logseq client can/will request files it hasn't uploaded yet, the
201// map will contain nil entries for requested files that don't exist
202func (d *DB) BatchFileMeta(ctx context.Context, id db.GraphID, fIDs []db.FileID) (map[db.FileID]*db.FileMeta, error) {
203 fms, err := d.q.BatchFileMetas(ctx, sqlitedb.BatchFileMetasParams{
204 GraphID: string(id),
205 FileIds: convSlice(fIDs, func(id db.FileID) string { return string(id) }),
206 })
207 if err != nil {
208 return nil, fmt.Errorf("failed to batch load file metadata: %w", err)
209 }
210 out := make(map[db.FileID]*db.FileMeta)
211 for _, fm := range fms {
212 out[db.FileID(fm.FileID)] = toFileMeta(fm)
213 }
214 return out, nil
215}
216
217func toFileMeta(fm sqlitedb.FileMeta) *db.FileMeta {
218 return &db.FileMeta{

Callers

nothing calls this directly

Implementers 2

DBdb/mem/mem.go
DBdb/sqlite/sqlite.go

Calls 4

FileIDTypeAlias · 0.92
convSliceFunction · 0.85
toFileMetaFunction · 0.85
BatchFileMetasMethod · 0.80

Tested by

no test coverage detected