This commit is contained in:
zhouxin 2021-05-23 09:32:29 +08:00
parent bbfbd4fb35
commit 596d09f5ae
3 changed files with 13 additions and 11 deletions

View File

@ -5,6 +5,6 @@ RUN cd /tmp/code && mvn clean package -Dmaven.test.skip=true -Dmaven.javadoc.ski
FROM openjdk:11-jdk-oracle FROM openjdk:11-jdk-oracle
COPY --from=maven /tmp/code/target/*.jar /webdav-teambition.jar COPY --from=maven /tmp/code/target/*.jar /webdav.jar
EXPOSE 8080 EXPOSE 8080
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/webdav-teambition.jar"] ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/webdav.jar"]

View File

@ -176,7 +176,8 @@ public class AliYunDriverClient {
} }
private String readRefreshToken() { private String readRefreshToken() {
Path path = Paths.get(aliYunDriveProperties.getRefreshTokenPath()); String refreshTokenPath = aliYunDriveProperties.getWorkDir() + "refresh-token";
Path path = Paths.get(refreshTokenPath);
if (!Files.exists(path, LinkOption.NOFOLLOW_LINKS)) { if (!Files.exists(path, LinkOption.NOFOLLOW_LINKS)) {
try { try {
@ -192,17 +193,18 @@ public class AliYunDriverClient {
return new String(bytes, StandardCharsets.UTF_8); return new String(bytes, StandardCharsets.UTF_8);
} }
} catch (IOException e) { } catch (IOException e) {
LOGGER.warn("读取refreshToken文件 {} 失败: ", aliYunDriveProperties.getRefreshTokenPath(), e); LOGGER.warn("读取refreshToken文件 {} 失败: ", refreshTokenPath, e);
} }
writeRefreshToken(aliYunDriveProperties.getRefreshToken()); writeRefreshToken(aliYunDriveProperties.getRefreshToken());
return aliYunDriveProperties.getRefreshToken(); return aliYunDriveProperties.getRefreshToken();
} }
private void writeRefreshToken(String newRefreshToken) { private void writeRefreshToken(String newRefreshToken) {
String refreshTokenPath = aliYunDriveProperties.getWorkDir() + "refresh-token";
try { try {
Files.write(Paths.get(aliYunDriveProperties.getRefreshTokenPath()), newRefreshToken.getBytes(StandardCharsets.UTF_8)); Files.write(Paths.get(refreshTokenPath), newRefreshToken.getBytes(StandardCharsets.UTF_8));
} catch (IOException e) { } catch (IOException e) {
LOGGER.warn("写入refreshToken文件 {} 失败: ", aliYunDriveProperties.getRefreshTokenPath(), e); LOGGER.warn("写入refreshToken文件 {} 失败: ", refreshTokenPath, e);
} }
aliYunDriveProperties.setRefreshToken(newRefreshToken); aliYunDriveProperties.setRefreshToken(newRefreshToken);
} }

View File

@ -7,7 +7,7 @@ public class AliYunDriveProperties {
private String url = "https://api.aliyundrive.com/v2"; private String url = "https://api.aliyundrive.com/v2";
private String authorization = ""; private String authorization = "";
private String refreshToken; private String refreshToken;
private String refreshTokenPath = "/etc/AliYunDriver-RefreshToken"; private String workDir = "/etc/aliyun-driver/";
private String agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_0_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"; private String agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_0_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36";
private String driveId; private String driveId;
@ -47,12 +47,12 @@ public class AliYunDriveProperties {
this.refreshToken = refreshToken; this.refreshToken = refreshToken;
} }
public String getRefreshTokenPath() { public String getWorkDir() {
return refreshTokenPath; return workDir;
} }
public void setRefreshTokenPath(String refreshTokenPath) { public void setWorkDir(String workDir) {
this.refreshTokenPath = refreshTokenPath; this.workDir = workDir;
} }
public void setDriveId(String driveId) { public void setDriveId(String driveId) {