This repository was archived by the owner on Sep 21, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -74,11 +74,25 @@ function get_Size($file) {
74
74
75
75
$ app ->get ("/api/directory/download/{dirpath} " , function (Request $ request , $ dirpath ) use ($ app ) {
76
76
77
- $ dirname = pathinfo ( $ dirpath)[ " basename " ];
77
+ if ( file_exists ( "{ $ app [ ' cakebox.root ' ]}{ $ dirpath}" ) && is_writable ( "{ $ app [ ' cakebox.root ' ]}{ $ dirpath } /../ " )) {
78
78
79
- $ p = new PharData ("{$ app ['cakebox.root ' ]}{$ dirpath }/../ {$ dirname }.tar " );
80
- $ p ->compress (Phar::NONE );
81
- $ p ->buildFromDirectory ("{$ app ['cakebox.root ' ]}{$ dirpath }" );
79
+ $ dirpath_info = pathinfo ($ dirpath );
80
+ $ dirname = $ dirpath_info ["basename " ];
81
+
82
+ if (!file_exists ("{$ app ['cakebox.root ' ]}{$ dirpath }/../ {$ dirname }.tar.inc " )) {
83
+ file_put_contents ("{$ app ['cakebox.root ' ]}{$ dirpath }/../ {$ dirname }.tar.inc " , "Tar creation in progress... " );
84
+
85
+ $ p = new PharData ("{$ app ['cakebox.root ' ]}{$ dirpath }/../ {$ dirname }.tar " );
86
+ $ p ->compress (Phar::NONE );
87
+ $ p ->buildFromDirectory ("{$ app ['cakebox.root ' ]}{$ dirpath }" );
88
+
89
+ unlink ("{$ app ['cakebox.root ' ]}{$ dirpath }/../ {$ dirname }.tar.inc " );
90
+ }
91
+ else
92
+ return $ app ->json ("Error: This directory is already under a tar process. " );
93
+ }
94
+ else
95
+ return $ app ->json ("Error: Directory doesn't exists or parent directory isn't writable. " );
82
96
83
97
return $ app ->json ("OK " );
84
98
})
You can’t perform that action at this time.
0 commit comments