Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
chore: support zip filetypes in the file cache
  • Loading branch information
Emyrk committed Jul 3, 2025
commit 642a3aa553c8dc063ae5189fac39b8e6c7ed6ec5
15 changes: 13 additions & 2 deletions coderd/files/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,21 @@ func fetch(store database.Store, fileID uuid.UUID) (CacheEntryValue, error) {
return CacheEntryValue{}, xerrors.Errorf("failed to read file from database: %w", err)
}

content := bytes.NewBuffer(file.Data)
var files fs.FS
switch file.Mimetype {
case "application/zip", "application/x-zip-compressed":
files, err = archivefs.FromZipReader(bytes.NewReader(file.Data), int64(len(file.Data)))
if err != nil {
return CacheEntryValue{}, xerrors.Errorf("failed to read zip file: %w", err)
}
case "application/x-tar":
default:
files = archivefs.FromTarReader(bytes.NewBuffer(file.Data))
}

return CacheEntryValue{
Object: file.RBACObject(),
FS: archivefs.FromTarReader(content),
FS: files,
Size: int64(len(file.Data)),
}, nil
}
Loading