Fossil SCM

Move the 'image.png' filename workaround for pasted images to avoid that attaching via file selection or drag/drop does not trigger the workaround. Remove stray debug output.

stephan 2026-06-04 19:19 UTC attach-v2
Commit 5fcc0dd3933baae5fb0dd68a62ad66c9b5921f8f0c38098a764996d8c0c7fe5b
1 file changed +7 -10
--- src/fossil.attach.js
+++ src/fossil.attach.js
@@ -296,10 +296,17 @@
296296
});
297297
const pasteImage = (event, item)=>{
298298
if( item.type.indexOf('image') === 0 ) {
299299
event.preventDefault();
300300
const blob = item.getAsFile();
301
+ if( blob.name === 'image.png' ){
302
+ /* Workaround to attempt to avoid name collisions when pasting
303
+ multiple images. We cannot, at this level, unambiguously
304
+ distinguish a ctrl-v of bitmap data vs a ctrl-v of an image
305
+ file copied via a desktop file manager. */
306
+ rowObj.overrideName = `pasted-image-${Date.now()}.png`;
307
+ }
301308
this.#injestBlob(rowObj, blob);
302309
return true;
303310
}
304311
return false;
305312
};
@@ -376,17 +383,10 @@
376383
}
377384
}
378385
379386
#injestBlob(rowObj, file){
380387
if( !file ) return;
381
- if( file.name === 'image.png' ){
382
- /* Workaround to attempt to avoid name collisions when pasting
383
- multiple images. We cannot, at this level, unambiguously
384
- distinguish a ctrl-v of bitmap data vs a ctrl-v of an image
385
- file copied via a desktop file manager. */
386
- rowObj.overrideName = `pasted-image-${Date.now()}.png`;
387
- }
388388
const old = this.#rowMatchingName(file.name);
389389
if( old && rowObj !== old ){
390390
/*
391391
Fossil attachments treat the name as a unique-per-target
392392
key, with the newest one being the primary. If a name is
@@ -399,15 +399,12 @@
399399
*/
400400
/* recycle `old` instead to avoid UI flicker. */
401401
this.#rowError(old);
402402
this.#removeRow(rowObj);
403403
rowObj.e = old.e;
404
- //if( rowObj.e.eDesc ) rowObj.e.eDesc.value = '';
405404
}
406
- console.warn("rowObj, old",rowObj, old);
407405
if( rowObj.overrideName ){
408
- console.warn("Renaming file to",rowObj.overrideName);
409406
file = new File([file], rowObj.overrideName, {type: file.type});
410407
rowObj.overrideName = undefined;
411408
}
412409
413410
let szLbl;
414411
--- src/fossil.attach.js
+++ src/fossil.attach.js
@@ -296,10 +296,17 @@
296 });
297 const pasteImage = (event, item)=>{
298 if( item.type.indexOf('image') === 0 ) {
299 event.preventDefault();
300 const blob = item.getAsFile();
 
 
 
 
 
 
 
301 this.#injestBlob(rowObj, blob);
302 return true;
303 }
304 return false;
305 };
@@ -376,17 +383,10 @@
376 }
377 }
378
379 #injestBlob(rowObj, file){
380 if( !file ) return;
381 if( file.name === 'image.png' ){
382 /* Workaround to attempt to avoid name collisions when pasting
383 multiple images. We cannot, at this level, unambiguously
384 distinguish a ctrl-v of bitmap data vs a ctrl-v of an image
385 file copied via a desktop file manager. */
386 rowObj.overrideName = `pasted-image-${Date.now()}.png`;
387 }
388 const old = this.#rowMatchingName(file.name);
389 if( old && rowObj !== old ){
390 /*
391 Fossil attachments treat the name as a unique-per-target
392 key, with the newest one being the primary. If a name is
@@ -399,15 +399,12 @@
399 */
400 /* recycle `old` instead to avoid UI flicker. */
401 this.#rowError(old);
402 this.#removeRow(rowObj);
403 rowObj.e = old.e;
404 //if( rowObj.e.eDesc ) rowObj.e.eDesc.value = '';
405 }
406 console.warn("rowObj, old",rowObj, old);
407 if( rowObj.overrideName ){
408 console.warn("Renaming file to",rowObj.overrideName);
409 file = new File([file], rowObj.overrideName, {type: file.type});
410 rowObj.overrideName = undefined;
411 }
412
413 let szLbl;
414
--- src/fossil.attach.js
+++ src/fossil.attach.js
@@ -296,10 +296,17 @@
296 });
297 const pasteImage = (event, item)=>{
298 if( item.type.indexOf('image') === 0 ) {
299 event.preventDefault();
300 const blob = item.getAsFile();
301 if( blob.name === 'image.png' ){
302 /* Workaround to attempt to avoid name collisions when pasting
303 multiple images. We cannot, at this level, unambiguously
304 distinguish a ctrl-v of bitmap data vs a ctrl-v of an image
305 file copied via a desktop file manager. */
306 rowObj.overrideName = `pasted-image-${Date.now()}.png`;
307 }
308 this.#injestBlob(rowObj, blob);
309 return true;
310 }
311 return false;
312 };
@@ -376,17 +383,10 @@
383 }
384 }
385
386 #injestBlob(rowObj, file){
387 if( !file ) return;
 
 
 
 
 
 
 
388 const old = this.#rowMatchingName(file.name);
389 if( old && rowObj !== old ){
390 /*
391 Fossil attachments treat the name as a unique-per-target
392 key, with the newest one being the primary. If a name is
@@ -399,15 +399,12 @@
399 */
400 /* recycle `old` instead to avoid UI flicker. */
401 this.#rowError(old);
402 this.#removeRow(rowObj);
403 rowObj.e = old.e;
 
404 }
 
405 if( rowObj.overrideName ){
 
406 file = new File([file], rowObj.overrideName, {type: file.type});
407 rowObj.overrideName = undefined;
408 }
409
410 let szLbl;
411

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button