소스 검색

HDFS-7162. Wrong path when deleting through fuse-dfs a file which already exists in trash (cmccabe)

Colin Patrick Mccabe 10 년 전
부모
커밋
03db9cc839
2개의 변경된 파일7개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 0
      hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
  2. 4 3
      hadoop-hdfs-project/hadoop-hdfs/src/main/native/fuse-dfs/fuse_trash.c

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -897,6 +897,9 @@ Release 2.6.0 - UNRELEASED
     HDFS-7178. Additional unit test for replica write with full disk.
     (Arpit Agarwal)
 
+    HDFS-7162. Wrong path when deleting through fuse-dfs a file which already
+    exists in trash (cmccabe)
+
     BREAKDOWN OF HDFS-6134 AND HADOOP-10150 SUBTASKS AND RELATED JIRAS
   
       HDFS-6387. HDFS CLI admin tool for creating & deleting an

+ 4 - 3
hadoop-hdfs-project/hadoop-hdfs/src/main/native/fuse-dfs/fuse_trash.c

@@ -150,13 +150,14 @@ int move_to_trash(const char *abs_path, hdfsFS userFS)
   if (ret) {
     goto done;
   }
-  if (!strncmp(trash_base, abs_path, strlen(trash_base))) {
+  int trash_base_len = strlen(trash_base);
+  if (!strncmp(trash_base, abs_path, trash_base_len)
+      && (strlen(abs_path) == trash_base_len || abs_path[trash_base_len] == '/')) {
     INFO("move_to_trash(%s): file is already in the trash; deleting.",
          abs_path);
     ret = ALREADY_IN_TRASH_ERR;
     goto done;
   }
-  fprintf(stderr, "trash_base='%s'\n", trash_base);
   if (asprintf(&target_dir, "%s%s", trash_base, parent_dir) < 0) {
     ret = ENOMEM;
     target_dir = NULL;
@@ -182,7 +183,7 @@ int move_to_trash(const char *abs_path, hdfsFS userFS)
     int idx;
     for (idx = 1; idx < TRASH_RENAME_TRIES; idx++) {
       free(target);
-      if (asprintf(&target, "%s%s.%d", target_dir, pcomp, idx) < 0) {
+      if (asprintf(&target, "%s/%s.%d", target_dir, pcomp, idx) < 0) {
         target = NULL;
         ret = ENOMEM;
         goto done;