File tree Expand file tree Collapse file tree
storage/src/main/java/org/commonjava/storage/pathmapped/core Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2929import java .io .OutputStream ;
3030import java .nio .file .Paths ;
3131
32+ import static java .lang .System .currentTimeMillis ;
3233import static org .commonjava .storage .pathmapped .util .PathMapUtils .getRandomFileId ;
3334
3435public class S3PhysicalStore implements PhysicalStore
@@ -55,13 +56,17 @@ public FileInfo getFileInfo( String fileSystem, String path )
5556 }
5657
5758 /**
58- * Some characters that might require special handling, like Colon ':'. This default impl is replacing colon
59- * with slash '/'. Derived classes can override the default behavior.
59+ * Some characters that might require special handling, like Colon ':'. This default impl replaces colon
60+ * with slash '/' and appends a timestamp to path to avoid conflict. (e.g, if a file is deleted and put again,
61+ * the new physical file can be removed by GC after the grace period if the 'storagefile' are same).
62+ * The timestamp uses the last 5 digital of current-time-millis.
6063 * @return valid S3 key string
6164 */
6265 protected String getS3Key ( String filesystem , String path )
6366 {
64- return Paths .get ( filesystem .replaceAll (":" , "/" ), path ).toString ();
67+ String tmp = Long .toString ( currentTimeMillis () );
68+ String timestamp = tmp .substring ( tmp .length () - 5 );
69+ return Paths .get ( filesystem .replaceAll (":" , "/" ), path + "." + timestamp ).toString ();
6570 }
6671
6772 @ Override
You can’t perform that action at this time.
0 commit comments