mirror of git://git.sysmocom.de/ofono
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.
This commit is contained in:
parent
31a4c0025d
commit
971bdfbe48
|
@ -3237,7 +3237,7 @@ GQueue *sms_tx_queue_load(const char *imsi)
|
||||||
struct dirent **entries;
|
struct dirent **entries;
|
||||||
int len;
|
int len;
|
||||||
int i;
|
int i;
|
||||||
unsigned long k;
|
unsigned long id;
|
||||||
|
|
||||||
if (imsi == NULL)
|
if (imsi == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -3250,17 +3250,18 @@ GQueue *sms_tx_queue_load(const char *imsi)
|
||||||
|
|
||||||
retq = g_queue_new();
|
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];
|
char uuid[SMS_MSGID_LEN * 2 + 1];
|
||||||
GSList *msg_list;
|
GSList *msg_list;
|
||||||
|
unsigned long oldid;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
char *oldpath, *newpath;
|
char *oldpath, *newpath;
|
||||||
struct txq_backup_entry *entry;
|
struct txq_backup_entry *entry;
|
||||||
struct dirent *dir = entries[i];
|
struct dirent *dir = entries[i];
|
||||||
char endc;
|
char endc;
|
||||||
|
|
||||||
if (sscanf(dir->d_name, "%*u-%lu-" SMS_MSGID_FMT "%c",
|
if (sscanf(dir->d_name, "%lu-%lu-" SMS_MSGID_FMT "%c",
|
||||||
&flags, uuid, &endc) != 2)
|
&oldid, &flags, uuid, &endc) != 3)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (strlen(uuid) != 2 * SMS_MSGID_LEN)
|
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);
|
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);
|
oldpath = g_strdup_printf("%s/%s", path, dir->d_name);
|
||||||
newpath = g_strdup_printf(SMS_TX_BACKUP_PATH_DIR,
|
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 directory to reflect new position in queue */
|
||||||
rename(oldpath, newpath);
|
rename(oldpath, newpath);
|
||||||
|
|
Loading…
Reference in New Issue