Browse Source

REPORT-101578 【版本管理三期】删除文件夹失败

new-design
Destiny.Lin 1 year ago
parent
commit
157069c230
  1. 11
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  2. 21
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java
  3. 3
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java

11
designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java

@ -407,11 +407,12 @@ public class TemplateTreePane extends JPanel implements FileOperations {
if (node instanceof FileNode) { if (node instanceof FileNode) {
FileNodeFILE nodeFILE = new FileNodeFILE((FileNode) node); FileNodeFILE nodeFILE = new FileNodeFILE((FileNode) node);
if (nodeFILE.exists()) { if (nodeFILE.exists()) {
try { if (!VcsHelper.getInstance().isLegacyMode()) {
WorkContext.getCurrent().get(VcsOperator.class).recycleVersion(VcsHelper.getInstance().getCurrentUsername(), VcsHelper.getInstance().dealWithFilePath(((FileNode) node).getEnvPath())); try {
} catch (Exception e) { WorkContext.getCurrent().get(VcsOperator.class).recycleVersion(VcsHelper.getInstance().getCurrentUsername(), nodeFILE.getPath());
FineLoggerFactory.getLogger().error("[VcsV2] recycle {} failed", nodeFILE.getName()); } catch (Exception e) {
return false; FineLoggerFactory.getLogger().error("[VcsV2] recycle {} failed", nodeFILE.getName());
}
} }
if (TemplateResourceManager.getResource().delete(nodeFILE)) { if (TemplateResourceManager.getResource().delete(nodeFILE)) {
HistoryTemplateListCache.getInstance().deleteFile(nodeFILE); HistoryTemplateListCache.getInstance().deleteFile(nodeFILE);

21
designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java

@ -27,6 +27,7 @@ import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent; import com.fr.workspace.WorkspaceEvent;
import com.fr.workspace.server.vcs.VcsFileUtils;
import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.VcsOperator;
import com.fr.workspace.server.vcs.filesystem.VcsFileSystem; import com.fr.workspace.server.vcs.filesystem.VcsFileSystem;
import com.fr.workspace.server.vcs.git.config.GcConfig; import com.fr.workspace.server.vcs.git.config.GcConfig;
@ -181,27 +182,9 @@ public class VcsHelper implements JTemplateActionListener {
private String getEditingFilename() { private String getEditingFilename() {
JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
String editingFilePath = jt.getEditingFILE().getPath(); String editingFilePath = jt.getEditingFILE().getPath();
return dealWithFilePath(editingFilePath); return VcsFileUtils.dealWithFilePath(editingFilePath);
} }
/**
* 处理传入的文件名使其符合Vcs规范
*
* @param filePath 文件路径
* @return 处理完的文件
*/
public String dealWithFilePath(String filePath) {
String vcsCacheDir = VcsFileSystem.getInstance().getVcsCacheRelativePath();
if (filePath.startsWith(ProjectConstants.REPORTLETS_NAME)) {
filePath = filePath.replaceFirst(ProjectConstants.REPORTLETS_NAME, StringUtils.EMPTY);
} else if (filePath.startsWith(vcsCacheDir)) {
filePath = filePath.replaceFirst(vcsCacheDir, StringUtils.EMPTY);
}
if (filePath.startsWith(VCS_FILE_SLASH)) {
filePath = filePath.substring(1);
}
return filePath;
}
private boolean needDeleteVersion(VcsEntity entity) { private boolean needDeleteVersion(VcsEntity entity) {
VcsConfigManager configManager = DesignerEnvManager.getEnvManager().getVcsConfigManager(); VcsConfigManager configManager = DesignerEnvManager.getEnvManager().getVcsConfigManager();

3
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java

@ -18,6 +18,7 @@ import com.fr.file.filetree.FileNode;
import com.fr.report.entity.VcsEntity; import com.fr.report.entity.VcsEntity;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsFileUtils;
import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.VcsOperator;
import javax.swing.Icon; import javax.swing.Icon;
@ -267,7 +268,7 @@ public class VcsNewPane extends RecyclePane {
@Override @Override
protected List<VcsTableEntity> getTableList() { protected List<VcsTableEntity> getTableList() {
List<VcsEntity> entityList = WorkContext.getCurrent().get(VcsOperator.class).getVersions(VcsHelper.getInstance().dealWithFilePath(filePath)); List<VcsEntity> entityList = WorkContext.getCurrent().get(VcsOperator.class).getVersions(VcsFileUtils.dealWithFilePath(filePath));
List<VcsTableEntity> tableEntities = new ArrayList<>(); List<VcsTableEntity> tableEntities = new ArrayList<>();
for (VcsEntity entity : entityList) { for (VcsEntity entity : entityList) {
tableEntities.add(new VcsTableEntity(entity)); tableEntities.add(new VcsTableEntity(entity));

Loading…
Cancel
Save