Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master' into lucene
Browse files Browse the repository at this point in the history
  • Loading branch information
jamebal committed May 20, 2024
2 parents fe39093 + 44574a1 commit 90a1f05
Show file tree
Hide file tree
Showing 11 changed files with 198 additions and 186 deletions.
34 changes: 34 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# .github/release-drafter.yml
name-template: 'v$NEXT_PATCH_VERSION'
tag-template: 'v$NEXT_PATCH_VERSION'
categories:
- title: '新功能 ✨'
labels:
- 'feature'
- title: '修复 🐛'
labels:
- 'bug'
- title: '优化 ⚡️'
labels:
- 'improvement'
change-template: '- $TITLE (#$NUMBER)'
no-changes-template: '- No changes'
template: |
[docker-docker.yml](https://github.com/jamebal/jmal-cloud-server/blob/master/docker-compose.example2.yml)
#### 更新前备份数据库
```shell
docker exec -it jmalcloud_mongodb mongodump -d jmalcloud -o /dump/$PREVIOUS_TAG --gzip --quiet
```
```shell
docker-compose pull && docker-compose up -d
```
## Changes in this release:
$CHANGES
**Full Changelog**: [$PREVIOUS_TAG...v$NEXT_PATCH_VERSION](https://github.com/jamebal/jmal-cloud-server/compare/$PREVIOUS_TAG...v$NEXT_PATCH_VERSION)
3 changes: 2 additions & 1 deletion .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: Build nightly

on:
push:
branches: [ master ]
branches:
- 'master'
workflow_dispatch:

jobs:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/nightly-nvidia-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: Build nightly (nvidia)

on:
push:
branches: [ master ]
branches:
- 'master'
workflow_dispatch:

jobs:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# .github/workflows/release-drafter.yml
name: Release Drafter

on:
push:
branches:
- master

jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
env:
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
79 changes: 0 additions & 79 deletions .github/workflows/release.yml

This file was deleted.

1 change: 1 addition & 0 deletions docker-compose.example2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ services:
TZ: Asia/Shanghai
volumes:
- ./docker/jmalcloud/mongodb/data/db:/data/db
- ./docker/jmalcloud/mongodb/backup:/dump
restart: unless-stopped
command: --wiredTigerCacheSizeGB 0.5
nginx:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.jmal</groupId>
<artifactId>clouddisk</artifactId>
<version>2.8.2</version>
<version>2.8.3</version>
<name>clouddisk</name>
<description>Cloud Disk</description>
<packaging>jar</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ public class CommonFileService {
@Autowired
public LuceneService luceneService;

/***
/**
* 上传文件夹的写入锁缓存
*/
private final Cache<String, Lock> uploadFolderLockCache = CaffeineUtil.getUploadFolderLockCache();
private final Cache<String, Lock> uploadFileLockCache = CaffeineUtil.getUploadFileLockCache();

protected static final Set<String> FILE_PATH_LOCK = new CopyOnWriteArraySet<>();

Expand Down Expand Up @@ -304,12 +304,9 @@ public String createFile(String username, File file, String userId, Boolean isPu
}

String fileAbsolutePath = file.getAbsolutePath();
Lock lock = null;
if (file.isDirectory()) {
lock = uploadFolderLockCache.get(fileAbsolutePath, key -> new ReentrantLock());
if (lock != null) {
lock.lock();
}
Lock lock = uploadFileLockCache.get(fileAbsolutePath, key -> new ReentrantLock());
if (lock != null) {
lock.lock();
}
UpdateResult updateResult;
ObjectId objectId = new ObjectId();
Expand Down Expand Up @@ -356,6 +353,7 @@ public String createFile(String username, File file, String userId, Boolean isPu
} finally {
if (lock != null) {
lock.unlock();
uploadFileLockCache.invalidate(fileAbsolutePath);
}
}
if (null != updateResult.getUpsertedId()) {
Expand Down Expand Up @@ -446,24 +444,28 @@ public void imageFileToWebp(File outputFile, BufferedImage image) throws IOExcep
}

private void setFileConfig(String fileId, String username, File file, String fileName, String suffix, String contentType, String relativePath, Update update) {
long size = file.length();
update.set("size", size);
update.set("md5", size + relativePath + fileName);
update.set(Constants.CONTENT_TYPE, getContentType(file, contentType));
update.set(Constants.SUFFIX, suffix);
if (contentType.contains(Constants.AUDIO)) {
setMusic(file, update);
}
if (contentType.contains(Constants.VIDEO)) {
setMediaCover(fileId, username, fileName, relativePath, update);
}
if (contentType.startsWith(Constants.CONTENT_TYPE_IMAGE) && (!"ico".equals(suffix) && !"svg".equals(suffix))) {
generateThumbnail(file, update);
}
if (contentType.contains(Constants.CONTENT_TYPE_MARK_DOWN) || "md".equals(suffix)) {
// 写入markdown内容
String markDownContent = FileUtil.readString(file, MyFileUtils.getFileCharset(file));
update.set("contentText", markDownContent);
try {
long size = file.length();
update.set("size", size);
update.set("md5", size + relativePath + fileName);
update.set(Constants.CONTENT_TYPE, getContentType(file, contentType));
update.set(Constants.SUFFIX, suffix);
if (contentType.contains(Constants.AUDIO)) {
setMusic(file, update);
}
if (contentType.contains(Constants.VIDEO)) {
setMediaCover(fileId, username, fileName, relativePath, update);
}
if (contentType.startsWith(Constants.CONTENT_TYPE_IMAGE) && (!"ico".equals(suffix) && !"svg".equals(suffix))) {
generateThumbnail(file, update);
}
if (contentType.contains(Constants.CONTENT_TYPE_MARK_DOWN) || "md".equals(suffix)) {
// 写入markdown内容
String markDownContent = FileUtil.readString(file, MyFileUtils.getFileCharset(file));
update.set("contentText", markDownContent);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}

Expand Down
16 changes: 8 additions & 8 deletions src/main/java/com/jmal/clouddisk/util/CaffeineUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ public class CaffeineUtil {
*/
private static Cache<String, Lock> chunkWriteLockCache;

/***
* 上传文件夹锁
/**
* 上传文件锁
*/
private static Cache<String, Lock> uploadFolderLockCache;
private static Cache<String, Lock> uploadFileLockCache;

/***
* 用户身份权限缓存
Expand Down Expand Up @@ -147,8 +147,8 @@ public static void initMyCache(){
if(chunkWriteLockCache == null){
chunkWriteLockCache = Caffeine.newBuilder().build();
}
if(uploadFolderLockCache == null) {
uploadFolderLockCache = Caffeine.newBuilder().expireAfterWrite(30, TimeUnit.MINUTES).build();
if(uploadFileLockCache == null) {
uploadFileLockCache = Caffeine.newBuilder().build();
}
}

Expand Down Expand Up @@ -180,11 +180,11 @@ public static Cache<String, Lock> getChunkWriteLockCache(){
return chunkWriteLockCache;
}

public static Cache<String, Lock> getUploadFolderLockCache(){
if(uploadFolderLockCache == null){
public static Cache<String, Lock> getUploadFileLockCache(){
if(uploadFileLockCache == null){
initMyCache();
}
return uploadFolderLockCache;
return uploadFileLockCache;
}

public static void setSpaceFull(String userId) {
Expand Down
Loading

0 comments on commit 90a1f05

Please sign in to comment.