Changeset 2348
- Timestamp:
- 07/22/07 14:48:22 (1 year ago)
- Files:
-
- plugins/file-sync/src/file_sync.c (modified) (5 diffs)
- plugins/file-sync/src/file_sync.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/file-sync/src/file_sync.c
r2347 r2348 66 66 } else if (!xmlStrcmp(cur->name, (const xmlChar *)"objtype")) { 67 67 dir->objtype = g_strdup(str); 68 } else if (!xmlStrcmp(cur->name, (const xmlChar *)"objformat")) { 69 dir->objformat = g_strdup(str); 68 70 } else if (!xmlStrcmp(cur->name, (const xmlChar *)"recursive")) { 69 71 dir->recursive = (g_ascii_strcasecmp(str, "TRUE") == 0); … … 267 269 osync_trace(TRACE_ENTRY, "%s(%p, %p, %p, %p)", __func__, data, info, ctx, change); 268 270 OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info); 271 OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env(info); 269 272 OSyncFileDir *dir = osync_objtype_sink_get_userdata(sink); 270 273 OSyncError *error = NULL; … … 289 292 /* No break. Continue below */ 290 293 case OSYNC_CHANGE_TYPE_MODIFIED: 294 291 295 //FIXME add ownership for file-sync 296 292 297 odata = osync_change_get_data(change); 293 298 g_assert(odata); 299 300 /* Convert to the configured store object format */ 301 if (dir->objformat && strcmp("file", dir->objformat)) { 302 303 OSyncFormatConverterPath *path = NULL; 304 305 OSyncObjFormat *fileformat = osync_format_env_find_objformat(formatenv, "file"); 306 OSyncObjFormat *targetformat = osync_format_env_find_objformat(formatenv, dir->objformat); 307 OSyncObjFormat *detectedFormat = osync_format_env_detect_objformat_full(formatenv, odata, &error); 308 309 /* Sanity check - if the converters are disable the engine sends not the requested "file" object format */ 310 if (fileformat == osync_data_get_objformat(odata)) { 311 /* Find converter path from file to detected format */ 312 path = osync_format_env_find_path(formatenv, fileformat, detectedFormat, &error); 313 314 if (!osync_format_env_convert(formatenv, path, odata, &error)) { 315 osync_error_set(&error, OSYNC_ERROR_EXISTS, "Can't convert to customized objformat."); 316 goto error; 317 } 318 } 319 320 /* Find converter path from detectedFormat to targetFromat. 321 This is needed to avoid shortcuts path: 322 "another object format with plain converter (or detector)" -> plain -> file 323 324 To be safe we convert $detectedFormat -> $targetformat in advance. 325 And later convert $targetformat to fileFormat. 326 */ 327 path = osync_format_env_find_path(formatenv, detectedFormat, targetformat, &error); 328 329 if (!osync_format_env_convert(formatenv, path, odata, &error)) { 330 osync_error_set(&error, OSYNC_ERROR_EXISTS, "Can't convert to customized objformat."); 331 goto error; 332 } 333 334 335 /* Find converter path fromat $targetformat to fileFormat. */ 336 path = osync_format_env_find_path(formatenv, targetformat, fileformat, &error); 337 338 if (!osync_format_env_convert(formatenv, path, odata, &error)) { 339 osync_error_set(&error, OSYNC_ERROR_EXISTS, "Can't convert to customized objformat."); 340 goto error; 341 } 342 343 } 344 294 345 osync_data_get_data(odata, &buffer, &size); 295 346 g_assert(buffer); … … 571 622 if (!osync_filesync_parse_settings(env, osync_plugin_info_get_config(info), error)) 572 623 goto error_free_env; 573 624 574 625 /* Now we register the objtypes that we can sync. This plugin is special. It can 575 626 * synchronize any objtype we configure it to sync and where a conversion … … 583 634 goto error_free_env; 584 635 636 637 if (!osync_format_env_find_objformat(formatenv, dir->objformat)) { 638 osync_error_set(error, OSYNC_ERROR_GENERIC, "Configured storage format \"%s\" for object type \"%s\" is unknown. Is the format plugin missing?"); 639 goto error_free_env; 640 } 641 642 585 643 dir->sink = sink; 586 644 587 / * The file format is the only one we understand */588 osync_objtype_sink_add_objformat(sink, "file");645 //osync_objtype_sink_add_objformat(sink, "file"); 646 osync_objtype_sink_add_objformat(sink, dir->objformat); 589 647 590 648 /* All sinks have the same functions of course */ plugins/file-sync/src/file_sync.h
r2347 r2348 45 45 typedef struct OSyncFileDir { 46 46 char *objtype; 47 char *objformat; 47 48 char *path; 48 49 GDir *dir;
