diff options
| author | Adam Spragg <adam@spra.gg> | 2022-05-23 15:00:28 +0100 | 
|---|---|---|
| committer | Adam Spragg <adam@spra.gg> | 2022-05-24 10:12:33 +0100 | 
| commit | 7c0520451b071e77b4c432ed89fc7559b8c58138 (patch) | |
| tree | 6516f87c94a67deabadc03a13eefeccb7a931b92 | |
| parent | 7292804c1bafd43389defc0d7b4352ada666d626 (diff) | |
Make "--no-mtime" apply to "dump" action
| -rw-r--r-- | man1/metastore.1 | 4 | ||||
| -rw-r--r-- | metastore.txt | 7 | ||||
| -rw-r--r-- | src/metaentry.c | 15 | ||||
| -rw-r--r-- | src/metaentry.h | 2 | ||||
| -rw-r--r-- | src/metastore.c | 2 | 
5 files changed, 18 insertions, 12 deletions
| diff --git a/man1/metastore.1 b/man1/metastore.1 index ee01dd8..f9d1755 100644 --- a/man1/metastore.1 +++ b/man1/metastore.1 @@ -49,10 +49,10 @@ Causes metastore to print less verbose messages. Can be repeated more than  once for even less verbosity.  .TP  .B \-m, \-\-mtime -Causes metastore to also take mtime into account for the compare or apply actions. +Causes metastore to take mtime into account for the compare or apply actions.  .TP  .B \-M, \-\-no\-mtime -Causes metastore to not save mtime in the metadata +Causes metastore to not take mtime into account for the dump or save actions.  .TP  .B \-e, \-\-empty\-dirs  Also attempts to recreate missing empty directories. May be useful where diff --git a/metastore.txt b/metastore.txt index ba81a05..351ccc4 100644 --- a/metastore.txt +++ b/metastore.txt @@ -51,11 +51,12 @@ OPTIONS                more than once for even less verbosity.         -m, --mtime -              Causes metastore to also take mtime into account for the compare -              or apply actions. +              Causes  metastore  to take mtime into account for the compare or +              apply actions.         -M, --no-mtime -              Causes metastore to not save mtime in the metadata +              Causes metastore to not take mtime into account for the dump  or +              save actions.         -e, --empty-dirs                Also attempts to recreate missing empty directories. May be use‐ diff --git a/src/metaentry.c b/src/metaentry.c index 9956f7f..7e90290 100644 --- a/src/metaentry.c +++ b/src/metaentry.c @@ -911,7 +911,7 @@ mentries_compare(struct metahash *mhashreal,  /* Dumps given metadata */  void -mentries_dump(struct metahash *mhash) +mentries_dump(struct metahash *mhash, int with_mtime)  {  	const struct metaentry *mentry;  	char mode[11 + 1] = ""; @@ -923,18 +923,23 @@ mentries_dump(struct metahash *mhash)  	for (int key = 0; key < HASH_INDEXES; key++) {  		for (mentry = mhash->bucket[key]; mentry; mentry = mentry->next) {  			strmode(mentry->mode, mode); -			if (mentry->mtimensec == MTIME_NONE) { -				snprintf(date, sizeof(date), "%19s", ""); +			if (!with_mtime) { +				date[0] = '\0'; +				nsec[0] = '\0'; +				zone[0] = '\0'; +			} +			else if (mentry->mtimensec == MTIME_NONE) { +				snprintf(date, sizeof(date), "\t%19s", "");  				snprintf(nsec, sizeof(nsec), "%10s", "");  				snprintf(zone, sizeof(zone), "%6s", "");  			}  			else {  				localtime_r(&mentry->mtime, &cal); -				strftime(date, sizeof(date), "%F %T", &cal); +				strftime(date, sizeof(date), "\t%F %T", &cal);  				snprintf(nsec, sizeof(nsec), ".%09ld", mentry->mtimensec);  				strftime(zone, sizeof(zone), " %z", &cal);  			} -			printf("%s\t%s\t%s\t%s%s%s\t%s%s\n", +			printf("%s\t%s\t%s%s%s%s\t%s%s\n",  			       mode,  			       mentry->owner, mentry->group,  			       date, nsec, zone, diff --git a/src/metaentry.h b/src/metaentry.h index 6c97961..fd28c17 100644 --- a/src/metaentry.h +++ b/src/metaentry.h @@ -94,6 +94,6 @@ void mentries_compare(struct metahash *mhashreal,                                      int cmp),                        msettings *st); -void mentries_dump(struct metahash *mhash); +void mentries_dump(struct metahash *mhash, int with_mtime);  #endif /* METAENTRY_H */ diff --git a/src/metastore.c b/src/metastore.c index bc5787e..2f6d9bc 100644 --- a/src/metastore.c +++ b/src/metastore.c @@ -585,7 +585,7 @@ main(int argc, char **argv)  			fixup_newemptydirs();  		break;  	case ACTION_DUMP: -		mentries_dump(real ? real : stored); +		mentries_dump(real ? real : stored, settings.do_mtime >= 0);  		break;  	} | 
