Skip to content

Commit

Permalink
update #100
Browse files Browse the repository at this point in the history
  • Loading branch information
yorukot committed May 8, 2024
1 parent 8be6998 commit 3aab760
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 34 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ All notable changes to this project will be documented in this file. Dates are d
- Support extract gz tar file [`b9aed84`](https://github.com/MHNightCat/superfile/commit/b9aed847804421e1fc4f03dcaefb0e27f1260ea3)
- Support transparent background [`4108d40`](https://github.com/MHNightCat/superfile/commit/4108d40bc0b93656eca2da98253a83dbc0cb27a9)
- Support custom border style [`6ff0576`](https://github.com/MHNightCat/superfile/commit/6ff05765823cbd25e6fdc4d3f7370e435114acbb)
- Enhancement when cutting and pasting, the file should be moved instead of copied and deleted. [`#100`](https://github.com/MHNightCat/superfile/issues/100)
- Support extract almose compressed file [`e57cb78`](https://github.com/MHNightCat/superfile/commit/e57cb78d602d62b47662e2069b75059d908147db)

#### Bug fix
- Fix Cut -> Paste file causes go panic [`#77`](https://github.com/MHNightCat/superfile/issues/77)
- Fix symlinked folders don't open within superfile [`#88`](https://github.com/MHNightCat/superfile/issues/88)


# [**v1.1.1**](https://github.com/MHNightCat/superfile/releases/tag/v1.1.1)

> 2024/04/23
Expand Down
2 changes: 1 addition & 1 deletion src/internal/file_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func pasteDir(src, dst string, id string, m model) (model, error) {
}

newPath := filepath.Join(dst, relPath)

if info.IsDir() {
newPath, err = renameIfDuplicate(newPath)
if err != nil {
Expand Down
55 changes: 29 additions & 26 deletions src/internal/handle_file_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,50 +538,53 @@ func pasteItem(m model) model {
processNewState: newProcess,
}

p := m.processBarModel.process[id]
for _, filePath := range m.copyItems.items {
p := m.processBarModel.process[id]
if m.copyItems.cut {
var err error
if m.copyItems.cut && !isExternalDiskPath(filePath) {
p.name = "󰆐 " + filepath.Base(filePath)
} else {
if m.copyItems.cut {
p.name = "󰆐 " + filepath.Base(filePath)
}
p.name = "󰆏 " + filepath.Base(filePath)
}

newModel, err := pasteDir(filePath, filepath.Join(panel.location, path.Base(filePath)), id, m)
m = newModel
errMessage := "cut item error"
if m.copyItems.cut && !isExternalDiskPath(filePath) {
err = moveElement(filePath, filepath.Join(panel.location, path.Base(filePath)))
} else {
newModel, err := pasteDir(filePath, filepath.Join(panel.location, path.Base(filePath)), id, m)
if err != nil {
errMessage = "paste item error"
}
m = newModel
if m.copyItems.cut {
os.RemoveAll(filePath)
}
}
p = m.processBarModel.process[id]
// Check if failure pasteItem
if err != nil {
p.state = failure
channel <- channelMessage{
messageId: id,
processNewState: p,
}
outPutLog("Pasted item error", err)
outPutLog(errMessage, err)
m.processBarModel.process[id] = p
break
} else {
if p.done == p.total {
p.state = successful
p.done = totalFiles
p.doneTime = time.Now()
channel <- channelMessage{
messageId: id,
processNewState: p,
}
}
m.processBarModel.process[id] = p
}
}

// If is cut delete orginal file
if m.copyItems.cut {
for _, item := range m.copyItems.items {
trashMacOrLinux(item)
}
if m.fileModel.filePanels[m.copyItems.originalPanel.index].location == m.copyItems.originalPanel.location {
m.fileModel.filePanels[m.copyItems.originalPanel.index].selected = panel.selected[:0]
}

p.state = successful
p.done = totalFiles
p.doneTime = time.Now()
channel <- channelMessage{
messageId: id,
processNewState: p,
}

m.processBarModel.process[id] = p
m.copyItems.cut = false
m.fileModel.filePanels[m.filePanelFocusIndex] = panel
return m
Expand Down
7 changes: 0 additions & 7 deletions src/internal/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,9 @@ type fileMetadata struct {
// Copied items
type copyItems struct {
items []string
originalPanel originalPanel
cut bool
}

// Original panel
type originalPanel struct {
index int
location string
}

/* FILE WINDOWS TYPE START*/
// Model for file windows
type fileModel struct {
Expand Down

0 comments on commit 3aab760

Please sign in to comment.