• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

oracle / opengrok / #3691

09 Nov 2023 04:15PM UTC coverage: 74.721% (+8.6%) from 66.08%
#3691

push

web-flow
avoid annotations for binary files (#4476)

fixes #4473

6 of 13 new or added lines in 4 files covered. (46.15%)

258 existing lines in 28 files now uncovered.

43797 of 58614 relevant lines covered (74.72%)

0.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

42.86
/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/IndexTimestamp.java
1
/*
2
 * CDDL HEADER START
3
 *
4
 * The contents of this file are subject to the terms of the
5
 * Common Development and Distribution License (the "License").
6
 * You may not use this file except in compliance with the License.
7
 *
8
 * See LICENSE.txt included in this distribution for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing Covered Code, include this CDDL HEADER in each
12
 * file and include the License file at LICENSE.txt.
13
 * If applicable, add the following below this CDDL HEADER, with the
14
 * fields enclosed by brackets "[]" replaced with your own identifying
15
 * information: Portions Copyright [yyyy] [name of copyright owner]
16
 *
17
 * CDDL HEADER END
18
 */
19

20
 /*
21
 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
22
 */
23
package org.opengrok.indexer.configuration;
24

25
import java.io.File;
26
import java.io.IOException;
27
import java.util.Date;
28
import java.util.logging.Level;
29
import java.util.logging.Logger;
30
import org.opengrok.indexer.logger.LoggerFactory;
31

32
public class IndexTimestamp {
1✔
33
    private transient Date lastModified;
34

35
    private static final Logger LOGGER = LoggerFactory.getLogger(IndexTimestamp.class);
1✔
36

37
    /**
38
     * Get the date of the last index update.
39
     *
40
     * @return the time of the last index update.
41
     */
42
    public Date getDateForLastIndexRun() {
43
        RuntimeEnvironment env = RuntimeEnvironment.getInstance();
×
44
        if (lastModified == null) {
×
45
            File timestamp = new File(env.getDataRootFile(), "timestamp");
×
46
            if (timestamp.exists()) {
×
47
                lastModified = new Date(timestamp.lastModified());
×
48
            }
49
        }
50
        return lastModified;
×
51
    }
52

53
    public void refreshDateForLastIndexRun() {
54
        lastModified = null;
×
55
    }
×
56

57
    public void stamp() throws IOException {
58
        RuntimeEnvironment env = RuntimeEnvironment.getInstance();
1✔
59
        File timestamp = new File(env.getDataRootFile(), "timestamp");
1✔
60
        String purpose = "used for timestamping the index database.";
1✔
61
        if (timestamp.exists()) {
1✔
62
            if (!timestamp.setLastModified(System.currentTimeMillis())) {
1✔
63
                LOGGER.log(Level.WARNING, "Failed to set last modified time on ''{0}'', {1}",
×
64
                    new Object[]{timestamp.getAbsolutePath(), purpose});
×
65
            }
66
        } else {
67
            if (!timestamp.createNewFile()) {
1✔
UNCOV
68
                LOGGER.log(Level.WARNING, "Failed to create file ''{0}'', {1}",
×
UNCOV
69
                    new Object[]{timestamp.getAbsolutePath(), purpose});
×
70
            }
71
        }
72
    }
1✔
73
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc