Skip to content
This repository has been archived by the owner on Feb 3, 2024. It is now read-only.

Commit

Permalink
fix: download not working for non-root partition
Browse files Browse the repository at this point in the history
  • Loading branch information
celestix committed Aug 26, 2023
1 parent 33ac388 commit 6cd04fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 60 deletions.
4 changes: 1 addition & 3 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ This document contains the list of things which might be added to the library in

2.) Handle documents with unknown content length.

3.) Add support for resuming downloads. (DONE)

4.) Fix downloads for different disk drives:
3.) Fix downloads for different disk drives:
warp: rename C:\Users\...\AppData\Roaming/warp/dldata/0dce3722/warp.dl D:\../100MB.bin: The system cannot move the file to a different disk drive.
61 changes: 4 additions & 57 deletions dloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ type Downloader struct {
l *log.Logger
lw io.WriteCloser
f *os.File
fName string
}

// Optional fields of downloader
Expand Down Expand Up @@ -222,7 +221,7 @@ func (d *Downloader) Start() (err error) {
}
defer func() {
d.f.Close()
err = os.Rename(d.fName, d.GetSavePath())
// err = os.Rename(d.fName, d.GetSavePath())
}()
d.Log("Starting download...")
d.ohmap.Make()
Expand Down Expand Up @@ -256,7 +255,7 @@ func (d *Downloader) Resume(parts map[int64]*ItemPart) (err error) {
}
defer func() {
d.f.Close()
err = os.Rename(d.fName, d.GetSavePath())
// err = os.Rename(d.fName, d.GetSavePath())
}()
d.Log("Resuming download...")
d.ohmap.Make()
Expand All @@ -276,8 +275,8 @@ func (d *Downloader) Resume(parts map[int64]*ItemPart) (err error) {
}

func (d *Downloader) openFile() (err error) {
d.fName = d.dlPath + "warp.dl"
d.f, err = os.OpenFile(d.fName,
// d.fName = d.dlPath + "warp.dl"
d.f, err = os.OpenFile(d.GetSavePath(),
os.O_RDWR|os.O_CREATE,
0666,
)
Expand Down Expand Up @@ -698,55 +697,3 @@ func (d *Downloader) prepareDownloader() (err error) {
}
return
}

// func (d *Downloader) compile() (err error) {
// // defer d.lw.Close()
// // svPath := strings.Join([]string{d.dlLoc, d.fileName}, "/")
// // err = os.Rename(d.fName, svPath)
// // return
// // d.handlers.CompileStartHandler("main")
// // svPath := strings.Join([]string{d.dlLoc, d.fileName}, "/")
// // offsets, partList := d.ohmap.Dump()
// // if len(offsets) == 1 {
// // hash := d.ohmap.GetUnsafe(offsets[0])
// // fName := getFileName(d.dlPath, hash)
// // err = os.Rename(fName, svPath)
// // return
// // }
// // file, ef := os.Create(svPath)
// // if ef != nil {
// // err = ef
// // return
// // }
// // sortInt64s(offsets)
// // d.Log("Compiling %d parts...", len(offsets))
// // d.Log("Compiling Parts: %v", partList)
// // for _, offset := range offsets {
// // hash := d.ohmap.GetUnsafe(offset)
// // fName := getFileName(
// // d.dlPath,
// // hash,
// // )
// // f, ef := os.Open(fName)
// // if ef != nil {
// // err = ef
// // return
// // }
// // _, err = io.Copy(file, NewProxyReader(f, func(n int) {
// // d.handlers.CompileProgressHandler("main", n)
// // }))
// // if err != nil {
// // return
// // }
// // defer func() {
// // er := os.Remove(fName)
// // if er != nil {
// // d.Log("Failed to remove part %s: %w", hash, er)
// // }
// // }()
// // }
// // d.Log("Compilation complete!")
// // d.handlers.CompileCompleteHandler("main", d.contentLength.v())
// // err = d.lw.Close()
// // return
// }

0 comments on commit 6cd04fa

Please sign in to comment.