You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by iilyak <gi...@git.apache.org> on 2015/10/06 17:27:31 UTC

[GitHub] couchdb-couch pull request: Export delete file

GitHub user iilyak opened a pull request:

    https://github.com/apache/couchdb-couch/pull/115

    Export delete file

    In order to support `rename_on_delete` semantics for views. We want to reuse `couch_server:delete_file` in couch_mrview_cleanup. 

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/cloudant/couchdb-couch export_delete_file

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/couchdb-couch/pull/115.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #115
    
----
commit d3ae946416a3a7abee1d487671d408a49c19bbbb
Author: ILYA Khlopotov <ii...@ca.ibm.com>
Date:   2015-10-06T15:12:59Z

    Export couch_server:delete_file for reuse

commit efa5e44f9f8875293bf05a65f2137c24de70656e
Author: ILYA Khlopotov <ii...@ca.ibm.com>
Date:   2015-10-06T15:14:15Z

    Check we keep extension doing rename_on_delete

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch pull request: Export delete file

Posted by iilyak <gi...@git.apache.org>.
Github user iilyak commented on the pull request:

    https://github.com/apache/couchdb-couch/pull/115#issuecomment-146250492
  
    I'll revert the UUID change and squash for final review.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch pull request: Export delete file

Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on a diff in the pull request:

    https://github.com/apache/couchdb-couch/pull/115#discussion_r41382938
  
    --- Diff: src/couch_server.erl ---
    @@ -549,9 +554,13 @@ delete_db_file(RootDir, FullFilePath, Options) ->
         end.
     
     rename_on_delete(Original) ->
    +    file:rename(Original, deleted_filename(Original)).
    +
    +deleted_filename(Original) ->
         {{Y,Mon,D}, {H,Min,S}} = calendar:universal_time(),
    +    UUID = ?b2l(couch_uuids:random()),
    --- End diff --
    
    I get what you intended but this seems awkward. Could delete_file instead return `ok | {renamed, NewName} | {error, Reason}` instead? Then we know where to look in the tests.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch pull request: Export delete file

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/couchdb-couch/pull/115


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch pull request: Export delete file

Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the pull request:

    https://github.com/apache/couchdb-couch/pull/115#issuecomment-146275519
  
    +1


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch pull request: Export delete file

Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the pull request:

    https://github.com/apache/couchdb-couch/pull/115#issuecomment-145903047
  
    +1, and nice cleanup of a cut-and-paste in the test. The assumption that the rename takes less than one second predates your change but it would be nice to get rid of it.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch pull request: Export delete file

Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on a diff in the pull request:

    https://github.com/apache/couchdb-couch/pull/115#discussion_r41280523
  
    --- Diff: src/couch_server.erl ---
    @@ -549,9 +554,12 @@ delete_db_file(RootDir, FullFilePath, Options) ->
         end.
     
     rename_on_delete(Original) ->
    +    file:rename(Original, renamed_filename(Original)).
    +
    +renamed_filename(Original) ->
    --- End diff --
    
    It's actually "deleted_filename", unless you make `deleted` suffix customizable.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch pull request: Export delete file

Posted by iilyak <gi...@git.apache.org>.
Github user iilyak commented on a diff in the pull request:

    https://github.com/apache/couchdb-couch/pull/115#discussion_r41401845
  
    --- Diff: src/couch_server.erl ---
    @@ -549,9 +554,13 @@ delete_db_file(RootDir, FullFilePath, Options) ->
         end.
     
     rename_on_delete(Original) ->
    +    file:rename(Original, deleted_filename(Original)).
    +
    +deleted_filename(Original) ->
         {{Y,Mon,D}, {H,Min,S}} = calendar:universal_time(),
    +    UUID = ?b2l(couch_uuids:random()),
    --- End diff --
    
    Good idea. I'll change it to return:
    - `{ok, deleted}`
    - `{ok, {renamed, FileName}}`
    - `{error, Reason}`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch pull request: Export delete file

Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the pull request:

    https://github.com/apache/couchdb-couch/pull/115#issuecomment-146244135
  
    +1 after reverting the uuid change. the original names were fine for uniqueness, the issue was the assumption that the test runs within one second (it would fail spuriously if the clock ticked between some steps).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-couch pull request: Export delete file

Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on a diff in the pull request:

    https://github.com/apache/couchdb-couch/pull/115#discussion_r41408779
  
    --- Diff: src/couch_server.erl ---
    @@ -538,20 +540,31 @@ db_closed(Server, Options) ->
             true -> Server
         end.
     
    -delete_db_file(RootDir, FullFilePath, Options) ->
    +delete_file(RootDir, FullFilePath, Options) ->
         Async = not lists:member(sync, Options),
         RenameOnDelete = config:get_boolean("couchdb", "rename_on_delete", false),
         case {Async, RenameOnDelete} of
             {_, true} ->
                 rename_on_delete(FullFilePath);
             {Async, false} ->
    -            couch_file:delete(RootDir, FullFilePath, Async)
    +            case couch_file:delete(RootDir, FullFilePath, Async) of
    +                ok -> {ok, deleted};
    +                Else -> Else
    +            end
         end.
     
     rename_on_delete(Original) ->
    +    DeletedFileName = deleted_filename(Original),
    +    case file:rename(Original, DeletedFileName) of
    +        ok -> {ok, {renamed, DeletedFileName}};
    +        Else -> Else
    +    end.
    +
    +deleted_filename(Original) ->
         {{Y,Mon,D}, {H,Min,S}} = calendar:universal_time(),
    +    UUID = ?b2l(couch_uuids:random()),
    --- End diff --
    
    no need for the uuid, timestamp suffices


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---