mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-12-22 17:41:53 +00:00
fix(web/app/controllers): do not move if there is any file in zip (#49)
There are some situations that need to place subfolder in data path. If there is any file but not only folder in path, do not move. Previous moving logic did not check about this.
This commit is contained in:
parent
73aec02216
commit
bd74ed3f51
@ -58,7 +58,7 @@
|
||||
if ($zip->open($up_filename) === TRUE){
|
||||
$zip->extractTo("/var/uoj_data/upload/{$problem['id']}");
|
||||
$zip->close();
|
||||
exec("cd /var/uoj_data/upload/{$problem['id']}; for sub_dir in `find -maxdepth 1 -type d ! -name .`; do mv -f \$sub_dir/* . && rm -rf \$sub_dir; done");
|
||||
exec("cd /var/uoj_data/upload/{$problem['id']}; if [ `find . -maxdepth 1 -type f`File = File ]; then for sub_dir in `find -maxdepth 1 -type d ! -name .`; do mv -f \$sub_dir/* . && rm -rf \$sub_dir; done; fi");
|
||||
echo "<script>alert('上传成功!')</script>";
|
||||
}else{
|
||||
$errmsg = "解压失败!";
|
||||
@ -705,7 +705,7 @@ EOD
|
||||
<div class="form-group">
|
||||
<label for="exampleInputFile">上传zip文件</label>
|
||||
<input type="file" name="problem_data_file" id="problem_data_file">
|
||||
<p class="help-block">说明:请将所有数据放置于压缩包根目录内。若压缩包内存在子文件夹,则会将这些一级子文件夹下的内容移动到根目录下,然后这些一级子文件夹删除;若这些子文件夹内存在同名文件,则会发生随机替换,仅保留一个副本。</p>
|
||||
<p class="help-block">说明:请将所有数据放置于压缩包根目录内。若压缩包内仅存在文件夹而不存在文件,则会将这些一级子文件夹下的内容移动到根目录下,然后这些一级子文件夹删除;若这些子文件夹内存在同名文件,则会发生随机替换,仅保留一个副本。</p>
|
||||
</div>
|
||||
<input type="hidden" name="problem_data_file_submit" value="submit">
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user