Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
PengyuDeng committed Aug 22, 2024
1 parent 6433961 commit 4172f16
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jetlinks.community.io.file;

import com.alibaba.excel.util.StringUtils;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.ByteBufUtil;
Expand All @@ -24,6 +25,7 @@
import org.springframework.http.codec.multipart.FilePart;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;

import java.io.File;
import java.nio.file.NoSuchFileException;
Expand Down Expand Up @@ -168,6 +170,9 @@ public Mono<FileInfo> saveFile(String name, Flux<DataBuffer> stream, FileOption.

@Override
public Mono<FileInfo> saveFile(String name, String folder, Flux<DataBuffer> stream, FileOption... options) {
if (folder.contains("/")) {
return Mono.error(new BusinessException("error.folder_cannot_contains:/"));
}
return doSaveFile(name, folder, stream, options);
}

Expand Down Expand Up @@ -277,6 +282,7 @@ public void handleDeleteEvent(EntityDeletedEvent<FileEntity> event) {
.map(entity -> Paths.get(properties.getStorageBasePath(), entity.getStoragePath()).toFile())
.filter(File::exists)
.map(File::delete)
.subscribeOn(Schedulers.boundedElastic())
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public Mono<Void> read(@PathVariable String fileId,
.getHeaders()
.getRange();
long position = 0;
if (ranges.size() != 0) {
if (!ranges.isEmpty()) {
position = ranges.get(0).getRangeStart(ctx.info().getLength());
}
ctx.position(position);
Expand Down

0 comments on commit 4172f16

Please sign in to comment.