Skip to content

Commit

Permalink
Mark when a file/folder enters the trash bin
Browse files Browse the repository at this point in the history
  • Loading branch information
DanThrane committed Oct 23, 2023
1 parent 231bc17 commit e7a9f09
Show file tree
Hide file tree
Showing 8 changed files with 484 additions and 460 deletions.
2 changes: 1 addition & 1 deletion backend/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023.3.8
2023.3.9
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
Expand Down Expand Up @@ -385,6 +386,10 @@ JNIEXPORT jint JNICALL Java_libc_LibC_umask(JNIEnv *env, jobject thisRef, jint m
return umask(mask);
}

JNIEXPORT jint JNICALL Java_libc_LibC_touchFile(JNIEnv *env, jobject thisRef, jint fileDescriptor) {
return futimes(fileDescriptor, NULL);
}

#ifdef __cplusplus
}
#endif
Binary file modified provider-integration/integration-module/native/libc_wrapper.so
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class LibC {
external fun resizePty(masterFd: Int, cols: Int, rows: Int): Int
external fun umask(mask: Int): Int

external fun touchFile(fileDescriptor: Int): Int

companion object {
init {
var didLoad = false
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import dk.sdu.cloud.utils.LinuxOutputStream
import dk.sdu.cloud.utils.copyTo
import io.ktor.util.*
import io.ktor.utils.io.pool.*
import libc.LibC
import libc.NativeStat
import libc.S_ISREG
import libc.clib
Expand Down Expand Up @@ -475,15 +476,22 @@ class NativeFS(

data class MoveShouldContinue(val needsToRecurse: Boolean)

suspend fun move(source: InternalFile, destination: InternalFile, conflictPolicy: WriteConflictPolicy): MoveShouldContinue {
suspend fun move(
source: InternalFile,
destination: InternalFile,
conflictPolicy: WriteConflictPolicy,
updateTimestamps: Boolean = false,
): MoveShouldContinue {
val sourceParent = openFile(source.parent())
val destinationParent = openFile(destination.parent())

try {
val sourceFd = LinuxFileHandle.createOrThrow(
clib.openat(sourceParent.fd, source.fileName(), 0, DEFAULT_FILE_MODE)
) { throw FSException.NotFound() }
val sourceStat = nativeStat(sourceFd, autoClose = true)
val sourceStat = nativeStat(sourceFd, autoClose = false)
if (updateTimestamps) clib.touchFile(sourceFd.fd)
sourceFd.close()
var shouldContinue = false

val desiredFileName = destination.fileName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class TrashTask(
nativeFs.move(
internalFile,
targetFile,
WriteConflictPolicy.RENAME
WriteConflictPolicy.RENAME,
updateTimestamps = true,
)

} catch (ex: FSException) {
Expand Down
6 changes: 6 additions & 0 deletions wiki/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ use.
Note that each service may have more than one deployment associated with it.
For details look in the `k8.kts` folders of each microservice.

## 23-10-23

```
Type 1/SDU Provider @ 2023.3.9
```

## 05-09-23

```
Expand Down

0 comments on commit e7a9f09

Please sign in to comment.