Skip to content

Commit

Permalink
feat: Proxy支持删除未同步的文件存储 #1836
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoxuwan committed Mar 8, 2024
1 parent 5be36a0 commit f801e9f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,17 @@ abstract class AbstractFileStorage<Credentials : StorageCredentials, Client> : F
throw UnsupportedOperationException("Copy operation unsupported")
}

open fun move(
fromPath: String,
fromName: String,
toPath: String,
toName: String,
fromClient: Client,
toClient: Client
) {
throw UnsupportedOperationException("Move operation unsupported")
}

companion object {
private val logger = LoggerFactory.getLogger(AbstractFileStorage::class.java)
private const val MAX_CACHE_CLIENT = 10L
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import java.nio.file.Paths
/**
* 本地文件存储客户端
*/
class FileSystemClient(private val root: String) {
class FileSystemClient(val root: String) {

constructor(path: Path) : this(path.toString())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ import com.tencent.bkrepo.common.storage.credentials.FileSystemCredentials
import com.tencent.bkrepo.common.storage.credentials.StorageCredentials
import java.io.File
import java.io.InputStream
import java.nio.file.Files
import java.nio.file.Paths
import java.nio.file.StandardCopyOption

/**
* 文件系统存储
Expand Down Expand Up @@ -76,4 +78,17 @@ open class FileSystemStorage : AbstractEncryptorFileStorage<FileSystemCredential
require(storageCredentials is FileSystemCredentials)
return Paths.get(storageCredentials.path, TEMP).toString()
}

override fun move(
fromPath: String,
fromName: String,
toPath: String,
toName: String,
fromClient: FileSystemClient,
toClient: FileSystemClient
) {
val fromFullPath = Paths.get(fromClient.root, fromPath, fromName)
val toFullPath = Paths.get(toClient.root, toPath, toName)
Files.move(fromFullPath, toFullPath, StandardCopyOption.REPLACE_EXISTING)
}
}

0 comments on commit f801e9f

Please sign in to comment.