diff options
author | Denis Kenzior <denkenz@gmail.com> | 2011-01-28 20:27:58 -0600 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2011-01-28 20:27:58 -0600 |
commit | 971bdfbe484ea8ce72b1a66aa27f53ba66037bfa (patch) | |
tree | 6687cac817da0510964c1a8913b3fe6caa22793a /src/smsutil.c | |
parent | 31a4c0025d05ba024fd70eafc09552955b5b98ee (diff) | |
download | ofono-971bdfbe484ea8ce72b1a66aa27f53ba66037bfa.tar.bz2 |
smsutil: Don't bother renaming to the same name
In sms_tx_queue_load, if the resulting file is the same (which is quite
often the case) then don't bother trying to rename it.
Diffstat (limited to 'src/smsutil.c')
-rw-r--r-- | src/smsutil.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/smsutil.c b/src/smsutil.c index 1ec89d8e..1c3b7980 100644 --- a/src/smsutil.c +++ b/src/smsutil.c @@ -3237,7 +3237,7 @@ GQueue *sms_tx_queue_load(const char *imsi) struct dirent **entries; int len; int i; - unsigned long k; + unsigned long id; if (imsi == NULL) return NULL; @@ -3250,17 +3250,18 @@ GQueue *sms_tx_queue_load(const char *imsi) retq = g_queue_new(); - for (i = 0, k = 0; i < len; i++) { + for (i = 0, id = 0; i < len; i++) { char uuid[SMS_MSGID_LEN * 2 + 1]; GSList *msg_list; + unsigned long oldid; unsigned long flags; char *oldpath, *newpath; struct txq_backup_entry *entry; struct dirent *dir = entries[i]; char endc; - if (sscanf(dir->d_name, "%*u-%lu-" SMS_MSGID_FMT "%c", - &flags, uuid, &endc) != 2) + if (sscanf(dir->d_name, "%lu-%lu-" SMS_MSGID_FMT "%c", + &oldid, &flags, uuid, &endc) != 3) continue; if (strlen(uuid) != 2 * SMS_MSGID_LEN) @@ -3277,9 +3278,15 @@ GQueue *sms_tx_queue_load(const char *imsi) g_queue_push_tail(retq, entry); + /* Don't bother re-shuffling the ids if they are the same */ + if (oldid == id) { + id++; + continue; + } + oldpath = g_strdup_printf("%s/%s", path, dir->d_name); newpath = g_strdup_printf(SMS_TX_BACKUP_PATH_DIR, - imsi, k++, flags, uuid); + imsi, id++, flags, uuid); /* rename directory to reflect new position in queue */ rename(oldpath, newpath); |