From b1d0de2cabb8a5a355fcd9f7215a0644f6dd08bb Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Thu, 11 Aug 2011 08:22:24 +0300 Subject: [PATCH] * minor --- src/mu-cmd.c | 4 ++-- src/mu-msg.c | 18 +++++++++++------- src/mu-store.cc | 2 +- src/mu-util.h | 5 ++++- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/mu-cmd.c b/src/mu-cmd.c index 2a388c7f..f03a7da0 100644 --- a/src/mu-cmd.c +++ b/src/mu-cmd.c @@ -314,7 +314,7 @@ cmd_mv_dev_null (MuConfig *opts) } if (opts->printtarget) - g_print ("%s\n", "/dev/null"); /* /dev/null */ + g_print ("/dev/null\n"); /* /dev/null */ return MU_EXITCODE_OK; } @@ -365,7 +365,7 @@ check_file_okay (const char *path, gboolean cmd_add) return FALSE; } - if (cmd_add && access (path, R_OK) != 0) { + if (cmd_add && access(path, R_OK) != 0) { g_warning ("path is not readable: %s: %s", path, strerror (errno)); return FALSE; diff --git a/src/mu-msg.c b/src/mu-msg.c index ecd731c8..cbabac2d 100644 --- a/src/mu-msg.c +++ b/src/mu-msg.c @@ -698,11 +698,11 @@ get_maildir_type (const char *path) * the closing '/'... if it does, remove it */ if (dirname[strlen(dirname) - 1 ] == G_DIR_SEPARATOR) dirname[strlen(dirname) - 1] = '\0'; - + if (g_str_has_suffix (dirname, "cur")) mtype = MAILDIR_TYPE_CUR; else if (g_str_has_suffix (dirname, "new")) - mtype = MAILDIR_TYPE_CUR; + mtype = MAILDIR_TYPE_NEW; else mtype = MAILDIR_TYPE_OTHER; @@ -739,9 +739,8 @@ get_new_fullpath (const char *oldpath, const char *targetmdir, filename); g_free (filename); - /* if flags != MU_MSG_FLAG_UNKNOWN, we update the filename for - * the new flags; in case the NEW flag is set/unset, this can - * also influence the dir */ + /* we update the filename for the new flags; in case the NEW + * flag is set/unset, this can also influence the dir */ if (flags != MU_MSG_FLAG_NONE) { gchar *tmp; tmp = mu_maildir_get_path_from_flags (newfullpath, flags); @@ -802,7 +801,7 @@ check_source_file (const char *src, MaildirType *mtype, GError **err) } *mtype = get_maildir_type (src); - if (mtype != MAILDIR_TYPE_CUR && *mtype != MAILDIR_TYPE_NEW) { + if (*mtype != MAILDIR_TYPE_CUR && *mtype != MAILDIR_TYPE_NEW) { g_set_error (err, 0, MU_ERROR_FILE, "source is not in a maildir: '%s'", src); return FALSE; @@ -859,7 +858,12 @@ mu_msg_file_move_to_maildir (const char* oldpath, const char* targetmdir, return FALSE; } - /* TODO: check for oldpath == newfullpath */ + if (g_strcmp0 (oldpath, newfullpath)) { + g_set_error (err, 0, MU_ERROR_FILE, + "target equals source"); + return FALSE; + } + rv = msg_move (oldpath, newfullpath, err); if (!rv) { g_free (newfullpath); diff --git a/src/mu-store.cc b/src/mu-store.cc index eb57d374..0b2deedc 100644 --- a/src/mu-store.cc +++ b/src/mu-store.cc @@ -121,7 +121,7 @@ add_synonym_for_flag (MuMsgFlags flag, Xapian::WritableDatabase *db) db->clear_synonyms (pfx + mu_msg_flag_name (flag)); db->add_synonym (pfx + mu_msg_flag_name (flag), pfx + - (std::string(1, mu_msg_flag_char (flag)))); + (std::string(1, tolower(mu_msg_flag_char (flag))))); } diff --git a/src/mu-util.h b/src/mu-util.h index c09f3610..442d695e 100644 --- a/src/mu-util.h +++ b/src/mu-util.h @@ -406,7 +406,9 @@ enum _MuExitCode { MU_EXITCODE_NO_MATCHES = 2, MU_EXITCODE_DB_LOCKED = 3, MU_EXITCODE_DB_CORRUPTED = 4, - MU_EXITCODE_DB_UPDATE_ERROR = 5 + MU_EXITCODE_DB_UPDATE_ERROR = 5, + + MU_EXITCODE_FILE_ERROR = 6 }; typedef enum _MuExitCode MuExitCode; @@ -432,6 +434,7 @@ enum _MuError { MU_ERROR_FILE_CANNOT_MKDIR, MU_ERROR_FILE_STAT_FAILED, MU_ERROR_FILE_READDIR_FAILED, + /* generic file-related error */ MU_ERROR_FILE,