-
Notifications
You must be signed in to change notification settings - Fork 1
/
task.go
33 lines (30 loc) · 729 Bytes
/
task.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package xls2sheets
import (
"net/http"
)
// NewTask creates the task
func NewTask(source *Source, target *Target) *Task {
t := &Task{
Source: source,
Target: target,
}
return t
}
// Run runs the refresh task
func (task *Task) Run(client *http.Client) error {
// fetch from source and upload to google drive
tempSpreadsheetID, err := task.Source.Process(client)
if err != nil {
return err
}
// this ensures that the temporary file is deleted at the end of
// conversion
if !task.LeaveJunk {
defer task.Source.Delete(client)
}
// copy data from temporary file to target file
if err := task.Target.Update(client, tempSpreadsheetID, task.Source.SheetAddressRange); err != nil {
return err
}
return nil
}