Skip to content

[WIP] Implement thumbnailssvc - #298

Closed
TheOneRing wants to merge 2 commits into
cs3org:masterfrom
TheOneRing:thumbnails
Closed

TheOneRing wants to merge 2 commits into
cs3org:masterfrom
TheOneRing:thumbnails

Conversation

@TheOneRing

Copy link
Copy Markdown
Contributor

No description provided.

@TheOneRing
TheOneRing requested a review from labkode as a code owner October 16, 2019 11:43
@labkode

labkode commented Oct 16, 2019

Copy link
Copy Markdown
Member

@TheOneRing can you rebase on top of master?

@TheOneRing
TheOneRing force-pushed the thumbnails branch 3 times, most recently from 1f3de8d to 1513631 Compare October 17, 2019 13:47
@labkode

labkode commented Oct 17, 2019

Copy link
Copy Markdown
Member

@TheOneRing Hi Hannah, thanks a lot for working on this PR. If it could help you in your implementation this is what we do in CERNBox for the ownCloud preview application to generate the thumbnails:
https://github.com/cernbox/revaold/blob/master/ocproxy/api/api.go#L5667

@refs refs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 correct a typo. Other than that I added some small comments regarding code style that might or might not be needed.

"github.com/rs/zerolog"
)

type thumnailhandler struct {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo. change to thumbnailHandler

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the type thumbnailHandler is not exported consider using non exported members. Here is a good read

return nil
}
t.Size = uint(size)
return &t

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could make the return more explicit by using struct literal, instead of mutating t along the way 🤷‍

httpClient := rhttp.GetHTTPClient(ctx)
httpReq, err := rhttp.NewRequest(ctx, "GET", t.URL, nil)
httpReq.Header = t.Request.Header.Clone()
if err != nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be one line above, in L:150, to save one instruction

return
}

newImage := resize.Thumbnail(t.Size, t.Size, image, resize.Lanczos3)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rename this to thumbnail to avoid confusion with the declared variable image

TempFileName string
}

func newThumbnailHandler(s *svc, w http.ResponseWriter, r *http.Request) *thumnailhandler {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functions are package scoped. a more appropriate name would be newHandler.

In general I'd move away from postfixing this with "-Handler" as it can be read as "thumbnailHandler implements the Handler interface" source. Instead, your type thumbnailHandler is an abstraction that does not implement such interface.

You're implementing the Handler interface on your thumbnails>service.go on svc method set

if err != nil {
t.Log.Err(err).Msg("Failed to partse host: " + s.conf.WebDavHost)
t.Writer.WriteHeader(http.StatusInternalServerError)
return nil

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the time being it does the job, but I wonder if it'd be possible not having this side effects, or decoupling the side effects from t and instead of mutating t along the body of the function, instead return a composite struct literal with the fields filled. It makes the logic easier to follow.

@TheOneRing
TheOneRing force-pushed the thumbnails branch 2 times, most recently from af2c675 to 13ea4b5 Compare October 30, 2019 16:02
Comment thread internal/http/services/loader/loader.go Outdated
_ "github.com/cs3org/reva/internal/http/services/owncloud/ocdav"
_ "github.com/cs3org/reva/internal/http/services/owncloud/ocs"
_ "github.com/cs3org/reva/internal/http/services/prometheus"
_ "github.com/cs3org/reva/internal/http/services/thumbnails"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheOneRing can you put the service also under owncloud like the ocdav and ocs are? Thanks!

@TheOneRing
TheOneRing force-pushed the thumbnails branch 2 times, most recently from 9520678 to f4ced19 Compare October 31, 2019 10:26
@butonic

butonic commented Apr 1, 2020 •

Copy link
Copy Markdown
Contributor

@labkode

labkode commented Apr 1, 2020

Copy link
Copy Markdown
Member

@labkode labkode closed this Apr 1, 2020
kobergj pushed a commit to kobergj/reva that referenced this pull request Jun 12, 2025
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.32.0 to 0.33.0.
- [Commits](golang/sys@v0.32.0...v0.33.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-version: 0.33.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants