« Return to Thread: [RFC] drop plugin batch_commit for 0.40?

Re: [RFC] drop plugin batch_commit for 0.40?

by Daniel Gollub-3 :: Rate this Message:

Reply to Author | View in Thread

On Monday 13 April 2009 05:18:44 pm Juergen Leising wrote:

> On Mon, Apr 13, 2009 at 02:09:45PM +0200, Daniel Gollub wrote:
> > Example:
> >
> > - commit() call with change UID: 00001
> > - plugin calls protocl specific code to commit change to peer
> > - plugins retrieves the new ID of the change which got just committed.
> > ID: 123 - plugin now needs to call osync_changet_set_uid(change, "123");
> > - then the commit function ends with osync_context_report_success()
> >
> > With the context reply (osync_context_report_sucess()) an internal
> > function get called which reports the new UID to the internal mapping
> > table.
>
> Oh, that's interesting.  Did you know, that the file-sync plugin
> changes the UID in file-sync/src/filename_scape.h   ?
> Unfortunately, the filenames are the actual carrier for the UIDs.
No - i missed that one. And you're right - thats causing a problem.
If filename_scape_characters() modifies the filename it's also required to
update the uid. I have prepared a patch - good you give it a try if this
solves the issue for your test secenario?

>
> This causes some trouble in the LDAP plugin, which does not
> expect such changes. I have tried a workaround in the LDAP plugin,
> but I am not too happy with it.
>
> So if I have understood you correctly, adding osync_changet_set_uid()
> anywhere in the file-sync plugin is the solution for the problems
> (which I do not fully overlook), isn't it?

Right. I hope my fix is doing this. Please let me know if this is working..

(I refactored the file-scape function call - so the diff got a big more
complex. There is no need to scape twice. Since there is not sink "write"
function anylonger. So currently it's guranteed that only the filesync_commit
function calls the _write() function).

Thanks for the hint!

Best Regards,
Daniel

--
Daniel Gollub                        Geschaeftsfuehrer: Ralph Dehner
FOSS Developer                       Unternehmenssitz:  Vohburg
B1 Systems GmbH                      Amtsgericht:       Ingolstadt
Mobil: +49-(0)-160 47 73 970         Handelsregister:   HRB 3537
EMail: gollub@...          http://www.b1-systems.de

Adresse: B1 Systems GmbH, Osterfeldstraße 7, 85088 Vohburg
http://pgpkeys.pca.dfn.de/pks/lookup?op=get&search=0xED14B95C2F8CA78D

[file-sync_uid_fix.diff]

Index: src/filename_scape.h
===================================================================
--- src/filename_scape.h (revision 5596)
+++ src/filename_scape.h (working copy)
@@ -28,15 +28,17 @@
 static const int reserved_count = 9;
 static const char scaper = '_';
 
-static void filename_scape_characters(char *input)
+static osync_bool filename_scape_characters(char *input)
 {
 
  int i;
+ osync_bool modified = FALSE;
 
  while (*input) {
  for (i = 0; i < reserved_count; ++i)
  if (*input ==  reserved_chars[i]) {
  *input++ = scaper;
+ modified = TRUE;
  goto done;
  }
  ++input;
@@ -44,6 +46,7 @@
  ;
  }
 
+ return modified;
 }
 
 #endif
Index: src/file_sync.c
===================================================================
--- src/file_sync.c (revision 5596)
+++ src/file_sync.c (working copy)
@@ -173,15 +173,9 @@
  char *buffer = NULL;
  unsigned int size = 0;
 
- char *filename = NULL, *tmp = NULL;
- if (!(tmp = strdup(osync_change_get_uid(change))))
- goto error;
+ char *filename = NULL;
+ filename = g_strdup_printf ("%s%c%s", dir->path, G_DIR_SEPARATOR, osync_change_get_uid(change));
 
- filename_scape_characters(tmp);
-
- filename = g_strdup_printf ("%s%c%s", dir->path, G_DIR_SEPARATOR, tmp);
- free(tmp);
-
  switch (osync_change_get_changetype(change)) {
  case OSYNC_CHANGE_TYPE_DELETED:
  if (!remove(filename) == 0) {
@@ -453,22 +447,25 @@
  OSyncFileDir *dir = userdata;
  OSyncHashTable *hashtable = osync_objtype_sink_get_hashtable(sink);
 
+ char *hash = NULL;
  char *filename = NULL, *tmp;
-
- if (!osync_filesync_write(sink, info, ctx, change, userdata)) {
- osync_trace(TRACE_EXIT_ERROR, "%s", __func__);
- return;
- }
+
  if (!(tmp = strdup(osync_change_get_uid(change)))) {
  osync_trace(TRACE_EXIT_ERROR, "%s", __func__);
  return;
  }
- filename_scape_characters(tmp);
 
- filename = g_strdup_printf ("%s/%s", dir->path, tmp);
+ if (filename_scape_characters(tmp))
+ osync_change_set_uid(change, tmp);
+
+ filename = g_strdup_printf ("%s%c%s", dir->path, G_DIR_SEPARATOR, tmp);
  free(tmp);
- char *hash = NULL;
 
+ if (!osync_filesync_write(sink, info, ctx, change, userdata)) {
+ osync_trace(TRACE_EXIT_ERROR, "%s", __func__);
+ return;
+ }
+
  if (osync_change_get_changetype(change) != OSYNC_CHANGE_TYPE_DELETED) {
  struct stat buf;
  stat(filename, &buf);


------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Opensync-devel mailing list
Opensync-devel@...
https://lists.sourceforge.net/lists/listinfo/opensync-devel

 « Return to Thread: [RFC] drop plugin batch_commit for 0.40?