Github messages for mblaze
 help / color / mirror / Atom feed
* [PR PATCH] mshow: do not increment extraction counter on errors
@ 2025-07-12 16:43 ferriff
  2025-07-12 17:12 ` ferriff
  0 siblings, 1 reply; 2+ messages in thread
From: ferriff @ 2025-07-12 16:43 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 475 bytes --]

There is a new pull request by ferriff against master on the mblaze repository

https://github.com/ferriff/mblaze mshow-fix
https://github.com/leahneukirchen/mblaze/pull/272

mshow: do not increment extraction counter on errors
Minimal changes to the base code to fix the return value of `mshow` when the extraction of an attachment fails, e.g., if a file of the same name already exists.

A patch file from https://github.com/leahneukirchen/mblaze/pull/272.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-mshow-fix-272.patch --]
[-- Type: text/x-diff, Size: 952 bytes --]

From e0bb3fa1dfed2bf1a8e5e29812cd7461c490a90c Mon Sep 17 00:00:00 2001
From: Federico Ferri <federico.ferri@cern.ch>
Date: Sat, 12 Jul 2025 18:29:23 +0200
Subject: [PATCH] mshow: do not increment extraction counter on errors

---
 mshow.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mshow.c b/mshow.c
index 5da1160..81acc0a 100644
--- a/mshow.c
+++ b/mshow.c
@@ -548,7 +548,7 @@ extract_mime(int depth, struct message *msg, char *body, size_t bodylen)
 					printf("%s\n", bufptr);
 					writefile(bufptr, body, bodylen);
 				}
-				extractcount++;
+				if (errno == 0) extractcount++;
 			} else if (filename &&
 			    fnmatch(a, filename, FNM_PATHNAME) == 0) {
 				// extract by name
@@ -569,7 +569,7 @@ extract_mime(int depth, struct message *msg, char *body, size_t bodylen)
 					printf("\n");
 					writefile(filename, body, bodylen);
 				}
-				extractcount++;
+				if (errno == 0) extractcount++;
 			}
 		}
 	}

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: mshow: do not increment extraction counter on errors
  2025-07-12 16:43 [PR PATCH] mshow: do not increment extraction counter on errors ferriff
@ 2025-07-12 17:12 ` ferriff
  0 siblings, 0 replies; 2+ messages in thread
From: ferriff @ 2025-07-12 17:12 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 627 bytes --]

New comment by ferriff on mblaze repository

https://github.com/leahneukirchen/mblaze/pull/272#issuecomment-3065881733

Comment:
This fix still leaves out the case of failures for `-x <msg>` with no further `id` or `filename` specifications.

For that, it might be better to count errors instead of success, i.e. change `extractcounter` into `extracterrors`, increment it if `errno != 0`, also for the case `extract_argc == 0`, ad change
```
	if ((xflag || Oflag) && extractcount < argc-optind) {
```
into
```
	if ((xflag || Oflag) && extracterrors) {
```

 If this latter solution is preferred, I can implement it.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-07-12 17:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-12 16:43 [PR PATCH] mshow: do not increment extraction counter on errors ferriff
2025-07-12 17:12 ` ferriff

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).