示例#1
0
func restoreSingleChunk(inputDir string, destDir string, filename string, file models.File) []string {
	out := []string{}

	chunk := file.Chunks[0]
	chunkSource := filepath.Join(inputDir, chunk.Name[0:2], chunk.Name[0:4], chunk.Name+EncSuffix)
	chunkDest := filepath.Join(destDir, filename)

	cmd := utils.GetDecryptCommand(chunkSource, chunkDest, passwordFile)
	out = append(out, cmd)

	return out
}
示例#2
0
func restoreMultipleChunks(inputDir string, destDir string, filename string, file models.File) []string {
	out := []string{}

	fileDest := filepath.Join(destDir, filename)
	concatList := []string{}
	delList := []string{}

	for chunkNo, chunk := range file.Chunks {
		chunkSource := filepath.Join(inputDir, chunk.Name[0:2], chunk.Name[0:4], chunk.Name+EncSuffix)
		chunkDest := filepath.Join(destDir, fmt.Sprintf("%s.%d", filename, chunkNo+1))

		cmd := utils.GetDecryptCommand(chunkSource, chunkDest, passwordFile)

		out = append(out, cmd)
		concatList = append(concatList, chunkDest)
		delList = append(delList, getDeleteCmd(chunkDest))
	}

	out = append(out, getConcatCmd(concatList, fileDest))
	out = append(out, delList...)

	return out
}