aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/request-image-size.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-04-16 19:53:26 -0400
committerbobzel <zzzman@gmail.com>2025-04-16 19:53:26 -0400
commit49c571cb3f8db0732ac9b461890af2c09722c71b (patch)
treea31b354a56a98727ba8355779feb0bdd437db0dc /src/client/util/request-image-size.ts
parent32f6e2f9e96f16c9b1855a570a3fe4d5bf3e7d9c (diff)
fixed authorizing dropbox.
Diffstat (limited to 'src/client/util/request-image-size.ts')
-rw-r--r--src/client/util/request-image-size.ts38
1 files changed, 18 insertions, 20 deletions
diff --git a/src/client/util/request-image-size.ts b/src/client/util/request-image-size.ts
index 32ab23618..798390c7d 100644
--- a/src/client/util/request-image-size.ts
+++ b/src/client/util/request-image-size.ts
@@ -33,27 +33,25 @@ export function requestImageSize(url: string): Promise<ISizeCalculationResult> {
res.on('data', chunk => {
buffer = Buffer.concat([buffer, chunk]);
- });
-
- res.on('error', reject);
-
- res.on('end', () => {
- try {
- size = imageSize(buffer);
- if (size) {
- resolve(size);
- req.abort();
+ })
+ .on('error', reject)
+ .on('end', () => {
+ try {
+ size = imageSize(buffer);
+ if (size) {
+ resolve(size);
+ req.abort();
+ }
+ } catch (err) {
+ /* empty */
+ console.log('Error: ', err);
+ }
+ if (!size) {
+ reject(new Error('Image has no size'));
+ return;
}
- } catch (err) {
- /* empty */
- console.log('Error: ', err);
- }
- if (!size) {
- reject(new Error('Image has no size'));
- return;
- }
- resolve(size);
- });
+ resolve(size);
+ });
});
req.on('error', reject);