mirror of
https://github.com/fiatjaf/nak.git
synced 2025-12-14 10:58:52 +00:00
fs: logging and proper (?) handling of context passing (basically now we ignore the context given to us by the fuse library because they're weird).
This commit is contained in:
@@ -30,7 +30,7 @@ type EntityDir struct {
|
||||
|
||||
var _ = (fs.NodeGetattrer)((*EntityDir)(nil))
|
||||
|
||||
func (e *EntityDir) Getattr(ctx context.Context, f fs.FileHandle, out *fuse.AttrOut) syscall.Errno {
|
||||
func (e *EntityDir) Getattr(_ context.Context, f fs.FileHandle, out *fuse.AttrOut) syscall.Errno {
|
||||
publishedAt := uint64(e.evt.CreatedAt)
|
||||
out.Ctime = publishedAt
|
||||
|
||||
@@ -67,6 +67,8 @@ func CreateEntityDir(
|
||||
extension string,
|
||||
event *nostr.Event,
|
||||
) *fs.Inode {
|
||||
log := ctx.Value("log").(func(msg string, args ...any))
|
||||
|
||||
h := parent.EmbeddedInode().NewPersistentInode(
|
||||
ctx,
|
||||
&EntityDir{ctx: ctx, wd: wd, evt: event},
|
||||
@@ -179,14 +181,17 @@ func CreateEntityDir(
|
||||
defer cancel()
|
||||
r, err := http.NewRequestWithContext(ctx, "GET", url, nil)
|
||||
if err != nil {
|
||||
log("failed to load image %s: %s\n", url, err)
|
||||
return nil, 0
|
||||
}
|
||||
resp, err := http.DefaultClient.Do(r)
|
||||
if err != nil {
|
||||
log("failed to load image %s: %s\n", url, err)
|
||||
return nil, 0
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode >= 300 {
|
||||
log("failed to load image %s: %s\n", url, err)
|
||||
return nil, 0
|
||||
}
|
||||
w := &bytes.Buffer{}
|
||||
|
||||
Reference in New Issue
Block a user