Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Limit preview for large image files #503

Merged
merged 1 commit into from
Nov 22, 2015
Merged

Conversation

olivierlambert
Copy link
Contributor

Do not display a preview of content length greater than given in the config file (default: 512kb)

This was referenced Sep 30, 2015
@JocelynDelalande
Copy link
Collaborator

@olivierlambert please rebase on master (as tests have been fixed, and the one test we do have is somehow related to your PR ;-)). I'm reading/testing your PR right now.

@JocelynDelalande
Copy link
Collaborator

@olivierlambert oh and on a more pendantic side, could you please squash your commits and reword commit message to explain what it does (it's good to mention the ticket but the commit msg should be sufficient to know what it's about).

@JocelynDelalande
Copy link
Collaborator

First remark : why sending an empty preview ? better not to show any IMHO (the "…" thing on the first link pasted, which is a 50MB image).

screenshot-localhost 9000 2015-10-05 22-28-09

Second think, I'd suggest, setting the size on kB, there is little use setting it in octets IMHO :)

size = req.response.headers['content-length'];
} catch(e) {
size = {};
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe something more explicit than just catching all exceptions ?(I know, some existing code does like yo did), + are you sure {} is a valid size ? ;-)

@JocelynDelalande
Copy link
Collaborator

@olivierlambert ok, reviewed, see inline comments for details.

Rather than fetching the image fully, a first timeserver-side and a second time, fully, client-side, I would suggest, doing a HEAD request to get the content-size header and decide, based on that, if the client should or not display a preview.

@olivierlambert what do you think about all my comments ?

@olivierlambert
Copy link
Contributor Author

  • rebase on upstream to have tests running
  • squashing commits
  • better PR name
  • content size in kB
  • don't display any preview
  • fix exception
  • smart image fetching

@olivierlambert olivierlambert changed the title fix issue #500 Limit preview for large files Oct 6, 2015
@olivierlambert
Copy link
Contributor Author

@JocelynDelalande : I don't know where to start to avoid fetching the image as you requested. Would you like to do it in this PR or maybe as an optimisation in another one?

@olivierlambert olivierlambert changed the title Limit preview for large files Limit preview for large image files Oct 6, 2015
@olivierlambert olivierlambert force-pushed the master branch 2 times, most recently from aed3c2e to 5b749d1 Compare October 6, 2015 10:46
@@ -60,7 +61,9 @@ function parse(msg, url, res, client) {
thumb: "",
link: url
};

Copy link
Collaborator

Choose a reason for hiding this comment

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

whiteline error

@JocelynDelalande
Copy link
Collaborator

Ok, good for fixes :) thanks for your reactivity

@JocelynDelalande : I don't know where to start to avoid fetching the image as you requested.
in link.js, for the case of the image I think you should replace
Would you like to do it in this PR or maybe as an optimisation in another one?

I was thinking on this one, but ok, that's acceptable to do it in a second time.

Starting point would be to call something issuing the HEAD request before that fetch() call.

@JocelynDelalande
Copy link
Collaborator

@olivierlambert just tested again, you removed the empty "grey frame" but still the three dots on grey background are showing up on too big images.

Once that is fixed and the trivial whitespace thing, you'll have my 👍

@astorije
Copy link
Collaborator

@olivierlambert, any news on this? :)

@JocelynDelalande
Copy link
Collaborator

@olivierlambert bump ? it's almost done :)

@olivierlambert
Copy link
Contributor Author

Didn't get any message/alert previously sorry :/

What about the "whiteline error"? I don't understand the issue there.

And IIRC (1 month ago, I could be wrong...), there is no trivial way to remove the three dots.

@JocelynDelalande
Copy link
Collaborator

What about the "whiteline error"? I don't understand the issue there.

You include in your commit the removal of a white line, which seems something unrelated to your edit.

And IIRC (1 month ago, I could be wrong...), there is no trivial way to remove the three dots.

Do you think you could find some time to look again please ? (css may be the way ?) those three dots with no meaning at all are a really strange thing to see for the user.

@olivierlambert
Copy link
Contributor Author

1/ Oh okay, no problem with that.

2/ I'll try to take a look today

@olivierlambert
Copy link
Contributor Author

I can't avoid the client.emit("toggle", toggle); to happen, due to the current code architecture. AFAIK, there is two options:

  1. create a ugly hack to re-hide the toggle somehow
  2. find a better solution but this will lead to deep modifications

Or maybe I missed something, that's also another possibility ^^

@olivierlambert
Copy link
Contributor Author

Okay, you got exactly the same behavior for other type of content. Try to paste a link to a PDF for example, you'll have the same issue.

It's not related to this PR, so I'll push my version without the white space, and I suggest to create a dedicated issue for the other problem :)

@olivierlambert
Copy link
Contributor Author

@JocelynDelalande PR done with the latest bits of master. Also tested it, that's fine.

@JocelynDelalande
Copy link
Collaborator

It's not related to this PR, so I'll push my version without the white space, and I suggest to create a dedicated issue for the other problem :)

Fair enough :) Thanks for digging it.

👍

@astorije
Copy link
Collaborator

👍 and merging.

Thanks a lot @olivierlambert!!! Hope to see you again soon!

astorije added a commit that referenced this pull request Nov 22, 2015
Limit preview for large image files
@astorije astorije merged commit c8a696b into erming:master Nov 22, 2015
@olivierlambert
Copy link
Contributor Author

You are welcome :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants