Skip to content

Commit c62ce4e

Browse files
authored
Merge pull request #45 from picoded/fix-mongodb-fileworkspacemap-modifiedtimestamp
Fix bug in getting last modified timestamp
2 parents e2ac808 + d5b80a3 commit c62ce4e

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

USING_GRADLE.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Using Gradle to Build the project
2+
3+
This project uses gradle to install external dependencies, build the project (jar files), and execute tests.
4+
5+
## Gradle Version
6+
7+
The version of gradle required is Gradle 4.6, or as specified in `/gradle/wrapper/gradle-wrapper.properties`.
8+
9+
## Run tasks using gradlew instead of gradle
10+
11+
Run `./gradlew` instead of the globally installed `gradle` on your machine to execute gradle tasks.
12+
13+
This ensures that the correct version of gradle is used, and also downloads the required version of gradle.
14+
15+
## Tasks
16+
17+
### Build buildJavaCommonsCore
18+
19+
Run `./gradlew buildJavaCommonsCore` to build the JavaCommonsCore module.
20+
21+
### Build the jar packages
22+
23+
Run `./gradlew jar` to build the project and package as a jar.
24+
25+
Run `./gradlew shadowJar` to build the project and package as a shadow jar (dependencies are shaded)
26+
27+
Run `./gradlew fatJar` to build the project and package as a fat jar (dependencies are included, and not shaded)
28+
29+
Run `./gradlew buildAll` to build all 3 jars (jar, shadow jar, and fat jar).
30+
31+
Run `./gradlew testAndBuildAll` to run full test suite and build all 3 jars (jar, shadow jar, and fat jar).
32+
33+
## Setting up the project in IntelliJ
34+
1. Right click "settings.gradle" and click "Import Gradle Project"
35+
2. In the Gradle Tool Window, click the wrench, and then "Gradle Settings"
36+
3. Check "Download external annotations for dependencies" - this will allow code hinting to work
37+
4. Set "Use Gradle from" to "'gradle-wrapper.properties' file" to make sure it runs the correct version of gradle
38+
39+

src/main/java/picoded/dstack/mongodb/MongoDB_FileWorkspaceMap.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -848,10 +848,14 @@ public long backend_createdTimestamp(final String oid, final String filepath) {
848848
public long backend_modifiedTimestamp(final String oid, final String filepath) {
849849
// Lets build the query for the "root file"
850850
Bson query = Filters.eq("filename", oid + "/" + filepath);
851-
851+
852852
// Lets prepare the search
853-
GridFSFindIterable search = gridFSBucket.find(query).limit(1);
854-
853+
GridFSFindIterable search = gridFSBucket.find(query)
854+
// GridFS uses an index on the files collection using the filename and uploadDate fields.
855+
// Make sure to sort the query by uploadDate descending (-1) to ensure that we get the latest file.
856+
.sort((new Document()).append("uploadDate", -1 /* descending*/ ))
857+
.limit(1);
858+
855859
// Lets iterate the search result, and return true on an item
856860
try (MongoCursor<GridFSFile> cursor = search.iterator()) {
857861
if (cursor.hasNext()) {

0 commit comments

Comments
 (0)