diff --git a/lib/archive/tar.php b/lib/archive/tar.php
index c8b3d5e6266480618faafdf8ad614552c9c8bea8..f6efd6d0ecc6f7fd69fbe61c1f492611489e2003 100644
--- a/lib/archive/tar.php
+++ b/lib/archive/tar.php
@@ -56,14 +56,21 @@ class OC_Archive_TAR extends OC_Archive{
 	 * @return bool
 	 */
 	function addFolder($path){
-		$tmpBase=get_temp_dir().'/';
+		$tmpBase=OC_Helper::tmpFolder();
 		if(substr($path,-1,1)!='/'){
 			$path.='/';
 		}
 		if($this->fileExists($path)){
 			return false;
 		}
-		mkdir($tmpBase.$path);
+		$parts=explode('/',$path);
+		$folder=$tmpBase;
+		foreach($parts as $part){
+			$folder.='/'.$part;
+			if(!is_dir($folder)){
+				mkdir($folder);
+			}
+		}
 		$result=$this->tar->addModify(array($tmpBase.$path),'',$tmpBase);
 		rmdir($tmpBase.$path);
 		$this->fileList=false;