Skip to content

Commit 884bccd

Browse files
authored
Fix: Long paths not workin in Windows (paths equal or greater than 260 characters)
1 parent cc1ebbc commit 884bccd

File tree

7 files changed

+23
-4
lines changed

7 files changed

+23
-4
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2323
- Optimized index loading and folder navigation [`0e6000f`](https://github.com/ollm/OpenComic/commit/0e6000f00e445de98eab7cdfbf72ee9b0016bf26)
2424
- Error extracting files with 7zip if the file name contained UTF8 characters [`27c863b`](https://github.com/ollm/OpenComic/commit/27c863b6a9abd434e8855216100e5f8087ed1e73)
2525
- Fullscreen error [`d72813a`](https://github.com/ollm/OpenComic/commit/d72813abbb0320a94bee5b2881c2bfcd1f2084cf)
26-
- Files shared over a network in Windows do not open
26+
- Files shared over a network in Windows do not open [`bab197f`](https://github.com/ollm/OpenComic/commit/bab197fa11f89ae07a707e4f42ea144a5416f25f)
27+
- Long paths not workin in Windows (paths equal or greater than 260 characters)
2728

2829
## [v1.2.0](https://github.com/ollm/OpenComic/releases/tag/v1.2.0) (29-03-2024)
2930

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
"sanitize-html": "^2.13.0",
9595
"sha1": "^1.1.1",
9696
"sharp": "^0.33.3",
97+
"short-windows-path": "^1.0.0",
9798
"shosho": "^1.4.3",
9899
"ssh2-sftp-client": "^10.0.3",
99100
"tar-fs": "^3.0.6",

scripts/image.js

+10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ async function resize(fromImage, toImage, config = {})
44
{
55
if(sharp === false) sharp = require('sharp');
66

7+
fromImage = shortWindowsPath.generateSync(fromImage);
8+
79
config = {...{
810
width: 200,
911
fit: sharp.fit.inside,
@@ -74,6 +76,8 @@ async function resizeToCanvas(fromImage, config = {})
7476
{
7577
if(sharp === false) sharp = require('sharp');
7678

79+
fromImage = shortWindowsPath.generateSync(fromImage);
80+
7781
config = {...{
7882
// background: 'white',
7983
kernel: 'lanczos3',
@@ -113,6 +117,8 @@ async function resizeToBlob(fromImage, config = {})
113117
{
114118
if(sharp === false) sharp = require('sharp');
115119

120+
fromImage = shortWindowsPath.generateSync(fromImage);
121+
116122
config = {...{
117123
// background: 'white',
118124
kernel: 'lanczos3',
@@ -200,6 +206,8 @@ async function convertToPng(fromImage, toImage, config = {})
200206
{
201207
if(sharp === false) sharp = require('sharp');
202208

209+
fromImage = shortWindowsPath.generateSync(fromImage);
210+
203211
config = {...{
204212
// background: 'white',
205213
kernel: 'nearest',
@@ -226,6 +234,8 @@ async function convertToWebp(fromImage, toImage, config = {})
226234
{
227235
if(sharp === false) sharp = require('sharp');
228236

237+
fromImage = shortWindowsPath.generateSync(fromImage);
238+
229239
config = {...{
230240
// background: 'white',
231241
kernel: 'nearest',

scripts/opencomic.js

+7
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ const electron = require('electron'),
8383
sha1 = require('sha1'),
8484
p = require('path'),
8585
isEqual = require('lodash.isequal'),
86+
shortWindowsPath = require('short-windows-path'),
8687
$ = require('jquery');
8788

8889
require('jquery-bez');
@@ -1145,6 +1146,12 @@ hb.registerHelper('encodeSrcURI', function(string) {
11451146

11461147
});
11471148

1149+
hb.registerHelper('shortWindowsPath', function(string) {
1150+
1151+
return shortWindowsPath.generateSync(string);
1152+
1153+
});
1154+
11481155
hb.registerHelper('normalizeNumber', function(value, decimals) {
11491156

11501157
value = String(value);

scripts/reading/render.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ async function render(index, _scale = false, magnifyingGlass = false)
441441
}
442442
else
443443
{
444-
img.src = encodeSrcURI(img.dataset.src);
444+
img.src = encodeSrcURI(shortWindowsPath.generateSync(img.dataset.src));
445445
img.classList.remove('blobRendered', 'blobRender');
446446
img.style.imageRendering = '';
447447
}

templates/reading.content.right.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
{{else if ebook}}
4343
<!-- <iframe> -->
4444
{{else}}
45-
<img src="{{chain 'encodeSrcURI' 'invertBackslash' image}}" data-src="{{htmlQuote image}}" data-path="{{htmlQuote path}}" data-index="{{index}}">
45+
<img src="{{chain 'shortWindowsPath' 'encodeSrcURI' 'invertBackslash' image}}" data-src="{{htmlQuote image}}" data-path="{{htmlQuote path}}" data-index="{{index}}">
4646
{{/if}}
4747
</oc-img>
4848
</div>

templates/reading.content.right.images.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
{{else if ebook}}
2121
<!-- <iframe> -->
2222
{{else}}
23-
<img src="{{chain 'encodeSrcURI' 'invertBackslash' image}}" data-src="{{htmlQuote image}}" data-path="{{htmlQuote path}}" data-index="{{index}}">
23+
<img src="{{chain 'shortWindowsPath' 'encodeSrcURI' 'invertBackslash' image}}" data-src="{{htmlQuote image}}" data-path="{{htmlQuote path}}" data-index="{{index}}">
2424
{{/if}}
2525
</oc-img>
2626
{{/if}}

0 commit comments

Comments
 (0)