# \`mender-artifact install\` truncates large files

**URL:** <https://hub.mender.io/t/mender-artifact-install-truncates-large-files/1190>\
**Category:** General Discussions\
**Tags:** mender-artifact\
**Created:** [October 25, 2019, 1:22pm UTC](https://hub.mender.io/t/mender-artifact-install-truncates-large-files/1190 "2019-10-25T13:22:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sbaxter-izo](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/sbaxter-izo/32/548_2.png) [@sbaxter-izo](https://hub.mender.io/u/sbaxter-izo)\
**Post date:** [October 25, 2019, 1:22pm UTC](https://hub.mender.io/t/mender-artifact-install-truncates-large-files/1190/1 "2019-10-25T13:22:27Z")

</div>

Hi all! I’m on `mender-artifact` v3.1.0 and I’m seeing `mender-artifact install` truncate a large file when I try to install it into an artifact. I have a 23MB source file, and I’m running

```
$ mender-artifact install -m 0755 large_src_file artifact.mender:/dst_file
$ mender-artifact cp artifact.mender:/dst_file ./copy_of_large_src_file
$ ls -sh ./copy_of_large_src_file
32K ./copy_of_large_source_file

```

If I instead use `mender-artifact cp large_src_file artifact.mender:/dst_file` and copy the file back out, it has the full 23MB file.

This led me to look at the difference in code between `cp` and `install` and noticed a difference in how `mender-artifact` writes the file in the artifact partition. Here’s a patch of a change I made to `cli/artifact/copy.go` that seems to fix it.

```
From b38cbd02cb822be3895028dc0582c4b05ab30b09 Mon Sep 17 00:00:00 2001
From: Sam Baxter <sbaxter@izotope.com>
Date: Fri, 25 Oct 2019 13:13:53 +0000
Subject: [PATCH] Fix mender-artifact install for large files

diff --git a/cli/mender-artifact/copy.go b/cli/mender-artifact/copy.go
index 9c20454..052030a 100644
--- a/cli/mender-artifact/copy.go
+++ b/cli/mender-artifact/copy.go
@@ -161,7 +161,7 @@ func Install(c *cli.Context) (err error) {
                        return cli.NewExitError(fmt.Sprintf("%v", err), 1)
                }
                w = f
- if _, err = io.Copy(w, r); err != nil {
+ if err = f.CopyTo(c.Args().First()); err != nil {
                        return cli.NewExitError(fmt.Sprintf("%v", err), 1)
                }
                return nil
-- 
2.20.1

```

I guess I’m wondering 1) if this is a legitimate issue or if I’m missing something, and 2) does this patch look like the right way to fix this? I’m happy to make a PR and try to contribute this upstream if this looks good.

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [October 25, 2019, 1:23pm UTC](https://hub.mender.io/t/mender-artifact-install-truncates-large-files/1190/2 "2019-10-25T13:23:52Z")

</div>

Tagging @oleorhagen and @kacf who are the ones familiar with these parts of the code.

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [October 28, 2019, 7:35am UTC](https://hub.mender.io/t/mender-artifact-install-truncates-large-files/1190/3 "2019-10-28T07:35:34Z")

</div>

This has been fixed in mender-artifact 3.2.0, you should try that one!

---

<div class="post-metadata">

**Author:** ![sbaxter-izo](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/sbaxter-izo/32/548_2.png) [@sbaxter-izo](https://hub.mender.io/u/sbaxter-izo)\
**Post date:** [October 29, 2019, 2:43pm UTC](https://hub.mender.io/t/mender-artifact-install-truncates-large-files/1190/4 "2019-10-29T14:43:26Z")

</div>

Thanks for the quick reply, I’ll verify that works for me. Is there somewhere I can find release notes so that I can look for this sort of thing in the future?

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [October 30, 2019, 6:41am UTC](https://hub.mender.io/t/mender-artifact-install-truncates-large-files/1190/5 "2019-10-30T06:41:39Z")

</div>

You can see the release notes [here](https://docs.mender.io/2.2/release-information/release-notes-changelog#mender-artifact-320) (second bullet point for mender-artifact). It was released just two days before your initial post, so it was easy to miss I guess. 🙂

---

<div class="post-metadata">

**Author:** ![sbaxter-izo](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/sbaxter-izo/32/548_2.png) [@sbaxter-izo](https://hub.mender.io/u/sbaxter-izo)\
**Post date:** [October 30, 2019, 1:24pm UTC](https://hub.mender.io/t/mender-artifact-install-truncates-large-files/1190/6 "2019-10-30T13:24:01Z")

</div>

Ah, that’ll do it. Thanks again! Things are looking good on my end now.
