Re: backup deleting old files
- From: Robert Mibus <mibus bigpond com>
- To: Eskil Heyn Olsen <eskil eazel com>
- Cc: Vadim Strizhevsky <vadim optonline net>,mibus <mibus telstra com>, Chris Green <cmg dok org>,gnome-pilot-list <gnome-pilot-list gnome org>
- Subject: Re: backup deleting old files
- Date: Mon, 24 Jul 2000 16:55:26 +0930
On Tue, Jul 18, 2000 at 05:01:03PM +0930, Robert Mibus wrote:
> On Tue, Jul 18, 2000 at 03:28:21PM +0930, Robert Mibus wrote:
> > On Mon, Jul 17, 2000 at 05:13:48PM -0700, Eskil Heyn Olsen wrote:
>
> > ok then, ive just looked and it shouldnt be too hard.
> > ive got plenty of time this week (and its not exactly a lot of code) so it
> > should be done soon.
> ok, it was less than i expected :)
>
> it includes the sprintf change as req'd. the only thing it doesnt do is put
> an option in the capplet, someone else will have to do that, my gtk code
> sucks.
>
> the max number of backups should be limited to 100 or less. (who the hell
> needs more ?? :-).
>
> (diff -u against CVS)
>
> mibus
this patch stops the extra backup dirs from being moved (anything under
5 chars, actually), creates the dirs at load time (not every backed-up
file :-).
pls. apply to cvs (assuming you approve, of course :)
mibus
--
Robert Mibus <mibus@bigpond.com>
Build a system that even a fool can use and only a fool will want to use it.
? backup_conduit.c.
? gnome-pilot-pre5.patch
Index: TODO
===================================================================
RCS file: /cvs/gnome/gnome-pilot/conduits/backup/TODO,v
retrieving revision 1.2
diff -u -r1.2 TODO
--- TODO 1998/08/04 01:21:49 1.2
+++ TODO 2000/07/24 07:22:12
@@ -1,3 +1,2 @@
o implement "exclude files" things
-o fix the delete deleted db's
o implement run_config
Index: backup_conduit.c
===================================================================
RCS file: /cvs/gnome/gnome-pilot/conduits/backup/backup_conduit.c,v
retrieving revision 1.28
diff -u -r1.28 backup_conduit.c
--- backup_conduit.c 2000/07/18 10:07:36 1.28
+++ backup_conduit.c 2000/07/24 07:22:15
@@ -68,13 +68,21 @@
CONDUIT_CFG(c.gpilotd_methods)->log_error("Cannot open whatever...");
*/
}
+ for (i=0;i < ((*c)->no_of_backups);i++) {
+ temp_name = g_strdup_printf ("%s/%d", (*c)->backup_dir, i);
+ mkdir (temp_name, (mode_t)0755);
+ g_free (temp_name);
+ }
+ temp_name = g_strdup_printf ("%s/del", (*c)->backup_dir);
+ mkdir (temp_name, (mode_t)0755);
+ g_free (temp_name);
}
(*c)->files_in_backup = g_list_alloc();
dir = opendir ((*c)->backup_dir);
while ((entry = readdir (dir))) {
if (entry->d_name)
- if (*(entry->d_name) != '.') {
+ if (strlen(entry->d_name) > 4) { /* ignores ., .., 0-9999 */
if ((*c)->backup_dir[strlen((*c)->backup_dir)-1] == '/')
temp_name = g_strdup_printf ("%s%s", ((*c)->backup_dir), entry->d_name);
else
@@ -104,9 +112,7 @@
if (temp_list->data) {
backup_name = g_malloc (strlen (temp_list->data) + 6);
strcpy (backup_name, temp_list->data);
- sprintf (strrchr (backup_name, '/'), "/del");
- mkdir (backup_name, (mode_t)0755);
- strcat (backup_name, strrchr (temp_list->data, '/'));
+ sprintf (strrchr (backup_name, '/'), "/del/%s", strrchr (temp_list->data, '/') + 1);
g_message ("Deleting %s", (char *) temp_list->data);
g_message (" (to %s)", backup_name);
@@ -246,15 +252,13 @@
if (i) {
backup_name_from = g_malloc (strlen (name) + 6);
strcpy (backup_name_from, name);
- sprintf (strrchr (backup_name_from, '/'), "/%i/%s", i - 1, strrchr (name, '/') + 1);
+ sprintf (strrchr (backup_name_from, '/'), "/%d/%s", i - 1, strrchr (name, '/') + 1);
} else
backup_name_from = strdup (name);
backup_name_to = g_malloc (strlen (name) + 6);
strcpy (backup_name_to, name);
- sprintf (strrchr (backup_name_to, '/'), "/%i", i);
- mkdir (backup_name_to, (mode_t)0755);
- strcat (backup_name_to, strrchr (name, '/'));
+ sprintf (strrchr (backup_name_to, '/'), "/%d/%s", i, strrchr (name, '/') + 1);
g_message ("Moving backup from %s to %s", backup_name_from, backup_name_to);
if (rename (backup_name_from, backup_name_to) == -1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]