( ext ExternalTask, mapped MappedTask, extHash, outputDir, sourceName string, state *SyncState, existingIDs []string, now time.Time, )
| 133 | } |
| 134 | |
| 135 | func (e *Engine) createTask( |
| 136 | ext ExternalTask, |
| 137 | mapped MappedTask, |
| 138 | extHash, outputDir, sourceName string, |
| 139 | state *SyncState, |
| 140 | existingIDs []string, |
| 141 | now time.Time, |
| 142 | ) (SyncAction, error) { |
| 143 | nextResult := nextid.Calculate(existingIDs) |
| 144 | newID := nextResult.NextID |
| 145 | |
| 146 | action := SyncAction{ |
| 147 | ExternalID: ext.ExternalID, |
| 148 | LocalID: newID, |
| 149 | Title: ext.Title, |
| 150 | Reason: "created", |
| 151 | } |
| 152 | |
| 153 | if e.DryRun { |
| 154 | return action, nil |
| 155 | } |
| 156 | |
| 157 | filePath, err := WriteTaskFile(outputDir, newID, mapped, ext.ExternalID, sourceName) |
| 158 | if err != nil { |
| 159 | return SyncAction{}, err |
| 160 | } |
| 161 | |
| 162 | localHash, err := HashLocalFile(filePath) |
| 163 | if err != nil { |
| 164 | return SyncAction{}, fmt.Errorf("failed to hash new file: %w", err) |
| 165 | } |
| 166 | |
| 167 | action.FilePath = filePath |
| 168 | |
| 169 | state.Tasks[ext.ExternalID] = TaskState{ |
| 170 | ExternalID: ext.ExternalID, |
| 171 | LocalID: newID, |
| 172 | FilePath: filePath, |
| 173 | ExternalHash: extHash, |
| 174 | LocalHash: localHash, |
| 175 | LastSynced: now, |
| 176 | } |
| 177 | |
| 178 | return action, nil |
| 179 | } |
| 180 | |
| 181 | func (e *Engine) updateTask( |
| 182 | ext ExternalTask, |
no test coverage detected