(files []*FileInformation)
| 762 | } |
| 763 | |
| 764 | func (u *upstream) applyCreates(files []*FileInformation) (map[string]*FileInformation, error) { |
| 765 | files, err := u.filterChanges(files) |
| 766 | if err != nil { |
| 767 | return nil, err |
| 768 | } else if len(files) == 0 { |
| 769 | return nil, nil |
| 770 | } |
| 771 | |
| 772 | size := int64(0) |
| 773 | for _, c := range files { |
| 774 | if c.IsDirectory { |
| 775 | // Print changes |
| 776 | if u.sync.Options.Verbose || len(files) <= 3 { |
| 777 | u.sync.log.Infof("Upstream - Upload Folder '%s'", u.getRelativeUpstreamPath(c.Name)) |
| 778 | } |
| 779 | } else { |
| 780 | if u.sync.Options.Verbose || len(files) <= 3 { |
| 781 | u.sync.log.Infof("Upstream - Upload File '%s'", u.getRelativeUpstreamPath(c.Name)) |
| 782 | } |
| 783 | |
| 784 | size += c.Size |
| 785 | } |
| 786 | } |
| 787 | |
| 788 | u.sync.log.Infof("Upstream - Upload %d create change(s) (Uncompressed ~%0.2f KB)", len(files), float64(size)/1024.0) |
| 789 | defer u.sync.log.Debugf("Upstream - Done Uploading") |
| 790 | |
| 791 | // Create a pipe for reading and writing |
| 792 | reader, writer := io.Pipe() |
| 793 | defer reader.Close() |
| 794 | defer writer.Close() |
| 795 | |
| 796 | var archiver *Archiver |
| 797 | errorChan := make(chan error) |
| 798 | go func() { |
| 799 | var compressErr error |
| 800 | archiver, compressErr = u.compress(writer, files, u.ignoreMatcher) |
| 801 | errorChan <- compressErr |
| 802 | }() |
| 803 | |
| 804 | // upload the archive |
| 805 | err = u.uploadArchive(reader) |
| 806 | if err != nil { |
| 807 | return nil, errors.Wrap(err, "upload archive") |
| 808 | } |
| 809 | |
| 810 | // check if there was a compressing error |
| 811 | err = <-errorChan |
| 812 | if err != nil { |
| 813 | return nil, errors.Wrap(err, "compress archive") |
| 814 | } |
| 815 | |
| 816 | // finally update written files |
| 817 | for _, element := range archiver.WrittenFiles() { |
| 818 | u.sync.fileIndex.CreateDirInFileMap(path.Dir(element.Name)) |
| 819 | u.sync.fileIndex.fileMap[element.Name] = element |
| 820 | } |
| 821 |
no test coverage detected