~ubuntu-branches/ubuntu/raring/tracker/raring

« back to all changes in this revision

Viewing changes to src/libtracker-data/tracker-db-journal.c

  • Committer: Package Import Robot
  • Author(s): Michael Biebl
  • Date: 2011-08-26 00:26:14 UTC
  • mfrom: (4.3.17 sid)
  • Revision ID: package-import@ubuntu.com-20110826002614-4qjfs9jhh5gs4p13
Tags: 0.10.24-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
 
44
44
#include "tracker-db-journal.h"
45
45
 
 
46
#ifndef DISABLE_JOURNAL
 
47
 
46
48
#define MIN_BLOCK_SIZE    1024
47
49
 
48
50
/*
447
449
        int flags;
448
450
        int mode;
449
451
 
450
 
#ifdef DISABLE_JOURNAL
451
 
        g_critical ("Journal is disabled, yet a journal function got called");
452
 
#endif
453
 
 
454
452
        jwriter->cur_block_len = 0;
455
453
        jwriter->cur_pos = 0;
456
454
        jwriter->cur_entry_amount = 0;
526
524
        GError *n_error = NULL;
527
525
        gboolean ret;
528
526
 
529
 
#ifdef DISABLE_JOURNAL
530
 
        g_critical ("Journal is disabled, yet a journal function got called");
531
 
#endif
532
 
 
533
527
        directory = g_path_get_dirname (filename);
534
528
        if (g_strcmp0 (directory, ".")) {
535
529
                mode = S_IRWXU | S_IRWXG | S_IRWXO;
570
564
        gchar *filename_free = NULL;
571
565
        GError *n_error = NULL;
572
566
 
573
 
#ifdef DISABLE_JOURNAL
574
 
        g_critical ("Journal is disabled, yet a journal function got called");
575
 
#endif
576
 
 
577
567
        g_return_val_if_fail (writer.journal == 0, FALSE);
578
568
 
579
569
        if (filename == NULL) {
606
596
        gchar *filename;
607
597
        GError *n_error = NULL;
608
598
 
609
 
#ifdef DISABLE_JOURNAL
610
 
        g_critical ("Journal is disabled, yet a journal function got called");
611
 
#endif
612
 
 
613
599
        g_return_val_if_fail (ontology_writer.journal == 0, FALSE);
614
600
 
615
601
        filename = g_build_filename (g_get_user_data_dir (),
659
645
        GError *n_error = NULL;
660
646
        gboolean ret;
661
647
 
662
 
#ifdef DISABLE_JOURNAL
663
 
        g_critical ("Journal is disabled, yet a journal function got called");
664
 
#endif
665
 
 
666
648
        ret = db_journal_writer_shutdown (&writer, &n_error);
667
649
 
668
650
        if (n_error) {
683
665
const gchar *
684
666
tracker_db_journal_get_filename (void)
685
667
{
686
 
#ifdef DISABLE_JOURNAL
687
 
        g_critical ("Journal is disabled, yet a journal function got called");
688
 
#endif
689
 
 
690
668
        /* Journal doesn't have to be open to get the filename, for example when
691
669
         * the file didn't exist and it was attempted opened in only read mode. */
692
670
        return (const gchar*) writer.journal_filename;
732
710
gboolean
733
711
tracker_db_journal_start_transaction (time_t time)
734
712
{
735
 
#ifdef DISABLE_JOURNAL
736
 
        g_critical ("Journal is disabled, yet a journal function got called");
737
 
#endif
738
 
 
739
713
        return db_journal_writer_start_transaction (&writer, time,
740
714
                                                    TRANSACTION_FORMAT_DATA);
741
715
}
746
720
{
747
721
        GError *n_error = NULL;
748
722
 
749
 
#ifdef DISABLE_JOURNAL
750
 
        g_critical ("Journal is disabled, yet a journal function got called");
751
 
#endif
752
 
 
753
723
        if (!db_journal_ontology_init (&n_error)) {
754
724
 
755
725
                if (n_error) {
811
781
                                            gint         p_id,
812
782
                                            const gchar *object)
813
783
{
814
 
#ifdef DISABLE_JOURNAL
815
 
        g_critical ("Journal is disabled, yet a journal function got called");
816
 
#endif
817
 
 
818
784
        if (current_transaction_format == TRANSACTION_FORMAT_ONTOLOGY) {
819
785
                return TRUE;
820
786
        }
869
835
                                               gint p_id,
870
836
                                               gint o_id)
871
837
{
872
 
#ifdef DISABLE_JOURNAL
873
 
        g_critical ("Journal is disabled, yet a journal function got called");
874
 
#endif
875
 
 
876
838
        if (current_transaction_format == TRANSACTION_FORMAT_ONTOLOGY) {
877
839
                return TRUE;
878
840
        }
929
891
                                            gint         p_id,
930
892
                                            const gchar *object)
931
893
{
932
 
#ifdef DISABLE_JOURNAL
933
 
        g_critical ("Journal is disabled, yet a journal function got called");
934
 
#endif
935
 
 
936
894
        if (current_transaction_format == TRANSACTION_FORMAT_ONTOLOGY) {
937
895
                return TRUE;
938
896
        }
987
945
                                               gint p_id,
988
946
                                               gint o_id)
989
947
{
990
 
#ifdef DISABLE_JOURNAL
991
 
        g_critical ("Journal is disabled, yet a journal function got called");
992
 
#endif
993
 
 
994
948
        if (current_transaction_format == TRANSACTION_FORMAT_ONTOLOGY) {
995
949
                return TRUE;
996
950
        }
1047
1001
                                            gint         p_id,
1048
1002
                                            const gchar *object)
1049
1003
{
1050
 
#ifdef DISABLE_JOURNAL
1051
 
        g_critical ("Journal is disabled, yet a journal function got called");
1052
 
#endif
1053
 
 
1054
1004
        if (current_transaction_format == TRANSACTION_FORMAT_ONTOLOGY) {
1055
1005
                return TRUE;
1056
1006
        }
1105
1055
                                               gint p_id,
1106
1056
                                               gint o_id)
1107
1057
{
1108
 
#ifdef DISABLE_JOURNAL
1109
 
        g_critical ("Journal is disabled, yet a journal function got called");
1110
 
#endif
1111
 
 
1112
1058
        if (current_transaction_format == TRANSACTION_FORMAT_ONTOLOGY) {
1113
1059
                return TRUE;
1114
1060
        }
1150
1096
{
1151
1097
        gboolean ret;
1152
1098
 
1153
 
#ifdef DISABLE_JOURNAL
1154
 
        g_critical ("Journal is disabled, yet a journal function got called");
1155
 
#endif
1156
 
 
1157
1099
        g_return_val_if_fail (current_transaction_format != TRANSACTION_FORMAT_NONE, FALSE);
1158
1100
 
1159
1101
        if (current_transaction_format == TRANSACTION_FORMAT_ONTOLOGY) {
1170
1112
{
1171
1113
        GError *n_error = NULL;
1172
1114
 
1173
 
#ifdef DISABLE_JOURNAL
1174
 
        g_critical ("Journal is disabled, yet a journal function got called");
1175
 
#endif
1176
 
 
1177
1115
        g_return_val_if_fail (writer.journal > 0, FALSE);
1178
1116
        g_return_val_if_fail (current_transaction_format != TRANSACTION_FORMAT_NONE, FALSE);
1179
1117
 
1196
1134
gboolean
1197
1135
tracker_db_journal_truncate (gsize new_size)
1198
1136
{
1199
 
#ifdef DISABLE_JOURNAL
1200
 
        g_critical ("Journal is disabled, yet a journal function got called");
1201
 
#endif
1202
 
 
1203
1137
        g_return_val_if_fail (writer.journal > 0, FALSE);
1204
1138
 
1205
1139
        return (ftruncate (writer.journal, new_size) != -1);
1259
1193
        gboolean ret;
1260
1194
        GError *n_error = NULL;
1261
1195
 
1262
 
#ifdef DISABLE_JOURNAL
1263
 
        g_critical ("Journal is disabled, yet a journal function got called");
1264
 
#endif
1265
 
 
1266
1196
        g_return_val_if_fail (current_transaction_format != TRANSACTION_FORMAT_NONE, FALSE);
1267
1197
 
1268
1198
        if (current_transaction_format == TRANSACTION_FORMAT_ONTOLOGY) {
1293
1223
gboolean
1294
1224
tracker_db_journal_fsync (void)
1295
1225
{
1296
 
#ifdef DISABLE_JOURNAL
1297
 
        g_critical ("Journal is disabled, yet a journal function got called");
1298
 
#endif
1299
 
 
1300
1226
        g_return_val_if_fail (writer.journal > 0, FALSE);
1301
1227
 
1302
1228
        return fsync (writer.journal) == 0;
1483
1409
        gboolean ret;
1484
1410
        GError *n_error = NULL;
1485
1411
 
1486
 
#ifdef DISABLE_JOURNAL
1487
 
        g_critical ("Journal is disabled, yet a journal function got called");
1488
 
#endif
1489
 
 
1490
1412
        ret = db_journal_reader_init (&reader, TRUE, filename, &n_error);
1491
1413
 
1492
1414
        if (n_error) {
1504
1426
        gboolean result;
1505
1427
        GError *n_error = NULL;
1506
1428
 
1507
 
#ifdef DISABLE_JOURNAL
1508
 
        g_critical ("Journal is disabled, yet a journal function got called");
1509
 
#endif
1510
 
 
1511
1429
        /* Used mostly for testing */
1512
1430
        if (G_UNLIKELY (filename)) {
1513
1431
                filename_used = g_strdup (filename);
1533
1451
gsize
1534
1452
tracker_db_journal_reader_get_size_of_correct (void)
1535
1453
{
1536
 
#ifdef DISABLE_JOURNAL
1537
 
        g_critical ("Journal is disabled, yet a journal function got called");
1538
 
#endif
1539
 
 
1540
1454
        g_return_val_if_fail (reader.file != NULL, FALSE);
1541
1455
 
1542
1456
        return (gsize) (reader.last_success - reader.start);
1628
1542
gboolean
1629
1543
tracker_db_journal_reader_shutdown (void)
1630
1544
{
1631
 
#ifdef DISABLE_JOURNAL
1632
 
        g_critical ("Journal is disabled, yet a journal function got called");
1633
 
#endif
1634
 
 
1635
1545
        return db_journal_reader_shutdown (&reader);
1636
1546
}
1637
1547
 
1944
1854
gboolean
1945
1855
tracker_db_journal_reader_next (GError **error)
1946
1856
{
1947
 
#ifdef DISABLE_JOURNAL
1948
 
        g_critical ("Journal is disabled, yet a journal function got called");
1949
 
#endif
1950
 
 
1951
1857
        return db_journal_reader_next (&reader, TRUE, error);
1952
1858
}
1953
1859
 
1960
1866
        JournalReader jreader = { 0 };
1961
1867
        GError *n_error = NULL;
1962
1868
 
1963
 
#ifdef DISABLE_JOURNAL
1964
 
        g_critical ("Journal is disabled, yet a journal function got called");
1965
 
#endif
1966
 
 
1967
1869
        if (db_journal_reader_init (&jreader, FALSE, filename, &n_error)) {
1968
1870
 
1969
1871
                if (jreader.end != jreader.current) {
2002
1904
tracker_db_journal_reader_get_resource (gint         *id,
2003
1905
                                        const gchar **uri)
2004
1906
{
2005
 
#ifdef DISABLE_JOURNAL
2006
 
        g_critical ("Journal is disabled, yet a journal function got called");
2007
 
#endif
2008
 
 
2009
1907
        g_return_val_if_fail (reader.file != NULL || reader.stream != NULL, FALSE);
2010
1908
        g_return_val_if_fail (reader.type == TRACKER_DB_JOURNAL_RESOURCE, FALSE);
2011
1909
 
2021
1919
                                         gint         *p_id,
2022
1920
                                         const gchar **object)
2023
1921
{
2024
 
#ifdef DISABLE_JOURNAL
2025
 
        g_critical ("Journal is disabled, yet a journal function got called");
2026
 
#endif
2027
 
 
2028
1922
        g_return_val_if_fail (reader.file != NULL || reader.stream != NULL, FALSE);
2029
1923
        g_return_val_if_fail (reader.type == TRACKER_DB_JOURNAL_INSERT_STATEMENT ||
2030
1924
                              reader.type == TRACKER_DB_JOURNAL_DELETE_STATEMENT ||
2047
1941
                                            gint *p_id,
2048
1942
                                            gint *o_id)
2049
1943
{
2050
 
#ifdef DISABLE_JOURNAL
2051
 
        g_critical ("Journal is disabled, yet a journal function got called");
2052
 
#endif
2053
 
 
2054
1944
        g_return_val_if_fail (reader.file != NULL || reader.stream != NULL, FALSE);
2055
1945
        g_return_val_if_fail (reader.type == TRACKER_DB_JOURNAL_INSERT_STATEMENT_ID ||
2056
1946
                              reader.type == TRACKER_DB_JOURNAL_DELETE_STATEMENT_ID ||
2074
1964
        guint current_file;
2075
1965
        static guint total_chunks = 0;
2076
1966
 
2077
 
#ifdef DISABLE_JOURNAL
2078
 
        g_critical ("Journal is disabled, yet a journal function got called");
2079
 
#endif
2080
 
 
2081
1967
        current_file = reader.current_file == 0 ? total_chunks -1 : reader.current_file -1;
2082
1968
 
2083
1969
        if (!rotating_settings.rotate_progress_flag) {
2289
2175
        return ret;
2290
2176
}
2291
2177
#endif /* GLib check */
 
2178
 
 
2179
#else /* DISABLE_JOURNAL */
 
2180
void
 
2181
tracker_db_journal_set_rotating (gboolean     do_rotating,
 
2182
                                 gsize        chunk_size,
 
2183
                                 const gchar *rotate_to)
 
2184
{
 
2185
        /* intentionally left blank, used for internal API compatibility */
 
2186
}
 
2187
#endif /* DISABLE_JOURNAL */