aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-01-24 15:07:09 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2009-01-24 15:07:09 +0000
commitc13cb737a5e78e5087714abe91e1c36917b93e0d (patch)
tree92f7f71f7afaa05b3e66e1b0a2efd1a197c2da76
parent12afca6d673bf3f44156a8275da5cad5bc4454e2 (diff)
downloadwydawca-c13cb737a5e78e5087714abe91e1c36917b93e0d.tar.gz
wydawca-c13cb737a5e78e5087714abe91e1c36917b93e0d.tar.bz2
Bugfixes
* src/diskio.c (archive_single_file): Fix errno value (ENOENT instead of EACCESS). Do not update STAT_ARCHIVES. (make_signame): New function. (archive_file): Use make_signame. (do_rmsymlink_file): Take 2nd argument, specifying whether to emit warning on errno==ENOENT. Update STAT_RMSYMLINKS. (rmsymlink_file): Attempt to remove .sig as well, if archive_signatures is set. Do not update STAT_RMSYMLINKS. git-svn-id: file:///svnroot/wydawca/trunk@339 6bb4bd81-ecc2-4fd4-a2d4-9571d19c0d33
-rw-r--r--ChangeLog14
-rw-r--r--src/diskio.c53
2 files changed, 47 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index a39bf5e..131da03 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2009-01-24 Sergey Poznyakoff <gray@gnu.org.ua>
+
+ * src/diskio.c (archive_single_file): Fix errno value (ENOENT
+ instead of EACCESS).
+ Do not update STAT_ARCHIVES.
+ (make_signame): New function.
+ (archive_file): Use make_signame.
+ (do_rmsymlink_file): Take 2nd argument, specifying whether to
+ emit warning on errno==ENOENT.
+ Update STAT_RMSYMLINKS.
+ (rmsymlink_file): Attempt to remove .sig as well, if
+ archive_signatures is set.
+ Do not update STAT_RMSYMLINKS.
+
2009-01-22 Sergey Poznyakoff <gray@gnu.org.ua>
* configure.ac, NEWS: Version 1.2
diff --git a/src/diskio.c b/src/diskio.c
index 2d185a1..3cffd10 100644
--- a/src/diskio.c
+++ b/src/diskio.c
@@ -506,8 +506,10 @@ archive_single_file (struct file_triplet *trp, struct directory_pair *dpair,
logmsg (LOG_DEBUG, "Archiving file `%s'", dst_file);
rc = do_archive_file (dst_file, dst_dir, file_name, &dpair->archive,
TRIPLET_UID (trp), TRIPLET_GID (trp), reldir);
+ if (rc == 0)
+ UPDATE_STATS (STAT_ARCHIVES);
}
- else if (errno == EACCES)
+ else if (errno == ENOENT)
{
if (!noentok)
logmsg (LOG_NOTICE, "Nothing to archive: file `%s' does not exist",
@@ -522,11 +524,24 @@ archive_single_file (struct file_triplet *trp, struct directory_pair *dpair,
free (dst_file);
free (dst_dir);
- if (rc == 0)
- UPDATE_STATS (STAT_ARCHIVES);
return rc;
}
+static char *
+make_signame (const char *file_name)
+{
+ size_t len;
+
+ if (((len = strlen (file_name)) > SUF_SIG_LEN
+ && memcmp (file_name + len - SUF_SIG_LEN, SUF_SIG, SUF_SIG_LEN)))
+ {
+ char *signame = xmalloc (len + SUF_SIG_LEN + 1);
+ strcpy (signame, file_name);
+ return strcat (signame, SUF_SIG);
+ }
+ return NULL;
+}
+
/* Archive the file FILE_NAME, located in DPAIR->dest_dir, and remove the
file. Get user IDs from the triplet TRP. Unless FILE_NAME ends in
".sig", do the same with FILE_NAME.sig, if such a file exists.
@@ -537,19 +552,13 @@ archive_file (struct file_triplet *trp, struct directory_pair *dpair,
const char *file_name, const char *reldir)
{
int rc;
- size_t len;
+ char *signame;
rc = archive_single_file (trp, dpair, file_name, reldir, 0);
- if (rc == 0 && archive_signatures &&
- ((len = strlen (file_name)) > SUF_SIG_LEN
- && memcmp (file_name + len - SUF_SIG_LEN, SUF_SIG, SUF_SIG_LEN)))
+ if (rc == 0 && archive_signatures && (signame = make_signame (file_name)))
{
- char *signame = xmalloc (len + SUF_SIG_LEN + 1);
- strcpy (signame, file_name);
- strcat (signame, SUF_SIG);
rc = archive_single_file (trp, dpair, signame, reldir, 1);
free (signame);
- return rc;
}
return rc;
}
@@ -682,7 +691,7 @@ symlink_file (struct file_triplet *trp, struct directory_pair *dpair,
/* Auxiliary function for rmsymlink_file (see below) */
static int
-do_rmsymlink_file (const char *dst_file)
+do_rmsymlink_file (const char *dst_file, int noentok)
{
struct stat st;
@@ -693,7 +702,8 @@ do_rmsymlink_file (const char *dst_file)
{
if (errno == ENOENT)
{
- logmsg (LOG_NOTICE, "Symlink `%s' does not exist", dst_file);
+ if (!noentok)
+ logmsg (LOG_NOTICE, "Symlink `%s' does not exist", dst_file);
return 0;
}
if (!S_ISLNK (st.st_mode))
@@ -703,13 +713,12 @@ do_rmsymlink_file (const char *dst_file)
return 1;
}
}
- if (dry_run_mode)
- return 0;
- if (unlink (dst_file))
+ if (!dry_run_mode && unlink (dst_file))
{
logmsg (LOG_ERR, "Cannot unlink %s: %s", dst_file, strerror (errno));
return 1;
}
+ UPDATE_STATS (STAT_RMSYMLINKS);
return 0;
}
@@ -724,6 +733,7 @@ rmsymlink_file (struct file_triplet *trp, struct directory_pair *dpair,
{
char *dst_file;
int rc = 0;
+ char *signame;
char *dst_dir = create_directory (dpair->dest_dir, reldir,
TRIPLET_UID (trp), TRIPLET_GID (trp));
@@ -741,12 +751,15 @@ rmsymlink_file (struct file_triplet *trp, struct directory_pair *dpair,
return 1;
}
- rc = do_rmsymlink_file (dst_file);
-
+ rc = do_rmsymlink_file (dst_file, 0);
+ if (rc == 0 && archive_signatures && (signame = make_signame (dst_file)))
+ {
+ rc = do_rmsymlink_file (signame, 1);
+ free (signame);
+ }
+
free (dst_file);
free (dst_dir);
- if (rc == 0)
- UPDATE_STATS (STAT_RMSYMLINKS);
return rc;
}

Return to:

Send suggestions and report system problems to the System administrator.