| 226 | | |
|---|
| 227 | | OSyncFileFormat *file = osync_try_malloc0(sizeof(OSyncFileFormat), &error); |
|---|
| 228 | | if (!file) |
|---|
| 229 | | goto error; |
|---|
| 230 | | file->path = g_strdup(osync_change_get_uid(change)); |
|---|
| 231 | | |
|---|
| 232 | | struct stat filestats; |
|---|
| 233 | | stat(filename, &filestats); |
|---|
| 234 | | file->userid = filestats.st_uid; |
|---|
| 235 | | file->groupid = filestats.st_gid; |
|---|
| 236 | | file->mode = filestats.st_mode; |
|---|
| 237 | | file->last_mod = filestats.st_mtime; |
|---|
| 238 | | |
|---|
| 239 | | if (!osync_file_read(filename, &(file->data), &(file->size), &error)) |
|---|
| 240 | | goto error_free_file; |
|---|
| 241 | | |
|---|
| 242 | | OSyncData *odata = osync_data_new((char *)file, sizeof(OSyncFileFormat), dir->objformat, &error); |
|---|
| 243 | | if (!odata) |
|---|
| 244 | | goto error_free_data; |
|---|
| 245 | | |
|---|
| | 227 | |
|---|
| | 228 | // Object format "file" |
|---|
| | 229 | if (!strcmp("file", osync_objformat_get_name(dir->objformat))) { |
|---|
| | 230 | OSyncFileFormat *file = osync_try_malloc0(sizeof(OSyncFileFormat), &error); |
|---|
| | 231 | if (!file) |
|---|
| | 232 | goto error; |
|---|
| | 233 | file->path = g_strdup(osync_change_get_uid(change)); |
|---|
| | 234 | |
|---|
| | 235 | struct stat filestats; |
|---|
| | 236 | stat(filename, &filestats); |
|---|
| | 237 | file->userid = filestats.st_uid; |
|---|
| | 238 | file->groupid = filestats.st_gid; |
|---|
| | 239 | file->mode = filestats.st_mode; |
|---|
| | 240 | file->last_mod = filestats.st_mtime; |
|---|
| | 241 | |
|---|
| | 242 | if (!osync_file_read(filename, &(file->data), &(file->size), &error)) { |
|---|
| | 243 | g_free(file->path); |
|---|
| | 244 | g_free(file); |
|---|
| | 245 | goto error; |
|---|
| | 246 | } |
|---|
| | 247 | |
|---|
| | 248 | odata = osync_data_new((char *)file, sizeof(OSyncFileFormat), dir->objformat, &error); |
|---|
| | 249 | if (!odata) { |
|---|
| | 250 | g_free(file->data); |
|---|
| | 251 | g_free(file->path); |
|---|
| | 252 | g_free(file); |
|---|
| | 253 | goto error; |
|---|
| | 254 | } |
|---|
| | 255 | |
|---|
| | 256 | // Any other object format |
|---|
| | 257 | } else { |
|---|
| | 258 | |
|---|
| | 259 | char *buf; |
|---|
| | 260 | unsigned int size; |
|---|
| | 261 | if (!osync_file_read(filename, &buf, &size, &error)) { |
|---|
| | 262 | osync_change_unref(change); |
|---|
| | 263 | osync_context_report_osyncwarning(ctx, error); |
|---|
| | 264 | osync_error_unref(&error); |
|---|
| | 265 | g_free(filename); |
|---|
| | 266 | } |
|---|
| | 267 | |
|---|
| | 268 | odata = osync_data_new(buf, size, dir->objformat, &error); |
|---|
| | 269 | if (!odata) { |
|---|
| | 270 | osync_change_unref(change); |
|---|
| | 271 | osync_context_report_osyncwarning(ctx, error); |
|---|
| | 272 | osync_error_unref(&error); |
|---|
| | 273 | } |
|---|
| | 274 | } |
|---|
| | 275 | |
|---|
| 427 | | if (!osync_file_read(filename, &(file->data), &(file->size), &error)) { |
|---|
| 428 | | osync_change_unref(change); |
|---|
| 429 | | osync_context_report_osyncwarning(ctx, error); |
|---|
| 430 | | osync_error_unref(&error); |
|---|
| 431 | | g_free(filename); |
|---|
| 432 | | continue; |
|---|
| 433 | | } |
|---|
| 434 | | |
|---|
| 435 | | OSyncData *odata = osync_data_new((char *)file, sizeof(OSyncFileFormat), directory->objformat, &error); |
|---|
| 436 | | if (!odata) { |
|---|
| 437 | | osync_change_unref(change); |
|---|
| 438 | | osync_context_report_osyncwarning(ctx, error); |
|---|
| 439 | | osync_error_unref(&error); |
|---|
| 440 | | continue; |
|---|
| | 441 | OSyncData *odata = NULL; |
|---|
| | 442 | |
|---|
| | 443 | // Objformat "file" |
|---|
| | 444 | if (!strcmp("file", osync_objformat_get_name(directory->objformat))) { |
|---|
| | 445 | OSyncFileFormat *file = osync_try_malloc0(sizeof(OSyncFileFormat), &error); |
|---|
| | 446 | if (!file) { |
|---|
| | 447 | osync_change_unref(change); |
|---|
| | 448 | osync_context_report_osyncwarning(ctx, error); |
|---|
| | 449 | osync_error_unref(&error); |
|---|
| | 450 | g_free(filename); |
|---|
| | 451 | g_free(relative_filename); |
|---|
| | 452 | continue; |
|---|
| | 453 | } |
|---|
| | 454 | file->path = g_strdup(relative_filename); |
|---|
| | 455 | |
|---|
| | 456 | if (!osync_file_read(filename, &(file->data), &(file->size), &error)) { |
|---|
| | 457 | osync_change_unref(change); |
|---|
| | 458 | osync_context_report_osyncwarning(ctx, error); |
|---|
| | 459 | osync_error_unref(&error); |
|---|
| | 460 | g_free(filename); |
|---|
| | 461 | continue; |
|---|
| | 462 | } |
|---|
| | 463 | |
|---|
| | 464 | odata = osync_data_new((char *)file, sizeof(OSyncFileFormat), directory->objformat, &error); |
|---|
| | 465 | if (!odata) { |
|---|
| | 466 | osync_change_unref(change); |
|---|
| | 467 | osync_context_report_osyncwarning(ctx, error); |
|---|
| | 468 | osync_error_unref(&error); |
|---|
| | 469 | continue; |
|---|
| | 470 | } |
|---|
| | 471 | // Any other specifc object format. |
|---|
| | 472 | } else { |
|---|
| | 473 | char *buf; |
|---|
| | 474 | unsigned int size; |
|---|
| | 475 | if (!osync_file_read(filename, &buf, &size, &error)) { |
|---|
| | 476 | osync_change_unref(change); |
|---|
| | 477 | osync_context_report_osyncwarning(ctx, error); |
|---|
| | 478 | osync_error_unref(&error); |
|---|
| | 479 | g_free(filename); |
|---|
| | 480 | continue; |
|---|
| | 481 | } |
|---|
| | 482 | |
|---|
| | 483 | odata = osync_data_new(buf, size, directory->objformat, &error); |
|---|
| | 484 | if (!odata) { |
|---|
| | 485 | osync_change_unref(change); |
|---|
| | 486 | osync_context_report_osyncwarning(ctx, error); |
|---|
| | 487 | osync_error_unref(&error); |
|---|
| | 488 | continue; |
|---|
| | 489 | } |
|---|