Bug 60361 - [EFL] EWebLauncher creates only one settings databases directory at startup.
Summary: [EFL] EWebLauncher creates only one settings databases directory at startup.
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit EFL (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords:
: 59238 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-05-06 04:32 PDT by Tomasz Morawski
Modified: 2011-11-03 18:32 PDT (History)
8 users (show)

See Also:


Attachments
Patch (6.14 KB, patch)
2011-05-06 04:33 PDT, Tomasz Morawski
no flags Details | Formatted Diff | Diff
Patch 2 (6.50 KB, patch)
2011-05-06 04:56 PDT, Tomasz Morawski
no flags Details | Formatted Diff | Diff
Patch 3 (6.62 KB, patch)
2011-05-11 00:28 PDT, Tomasz Morawski
kenneth: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tomasz Morawski 2011-05-06 04:32:09 PDT
The EWebLauncher should only create one directory to settings databases
while startup. Previous it creates two directories in /tmp and user's
home dir which only one was used.

Added settings databases path parameter to ewk_init function.
Comment 1 Tomasz Morawski 2011-05-06 04:33:39 PDT
Created attachment 92568 [details]
Patch
Comment 2 WebKit Review Bot 2011-05-06 04:35:21 PDT
Attachment 92568 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebKit/efl/ChangeLog', u'Source/Web..." exit_code: 1

Tools/ChangeLog:1:  ChangeLog entry has no bug number  [changelog/bugnumber] [5]
Total errors found: 1 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Tomasz Morawski 2011-05-06 04:56:09 PDT
Created attachment 92569 [details]
Patch 2
Comment 4 Luiz Agostini 2011-05-06 15:07:09 PDT
Comment on attachment 92569 [details]
Patch 2

View in context: https://bugs.webkit.org/attachment.cgi?id=92569&action=review

> Source/WebKit/efl/ewk/ewk_main.cpp:66
> +static Eina_Bool _ewk_init_body(const char *settings_db_path);

codding style: (const char* settings_db_path)

> Source/WebKit/efl/ewk/ewk_main.cpp:80
> +int ewk_init(const char *settings_db_path)

The same here.

> Source/WebKit/efl/ewk/ewk_main.cpp:166
> +Eina_Bool _ewk_init_body(const char *settings_db_path)

And here.

> Source/WebKit/efl/ewk/ewk_main.cpp:197
> +    if (!settings_db_path) {

Since you are creating the temp directory and returning from main() if temp directory creation fails, then it seems that all the code inside this if is dead code. Is it?
Would not be better to make the decision about which directory to use in main and make parameter settings_db_path obligatory?

> Source/WebKit/efl/ewk/ewk_main.cpp:201
> +        // check home directory first

codding style: // Check home directory first.

> Source/WebKit/efl/ewk/ewk_main.cpp:203
> +            // Exit now - otherwise you may have some crash later

codding style: missing period at the end of comment.

> Source/WebKit/efl/ewk/ewk_main.cpp:205
> +            CRITICAL("Can't access HOME dir (or /tmp) %s - no place to save databases: %s", path.utf8().data(), strerror(errnowas));

Why are you mentioning /temp if you made path = WebCore::homeDirectoryPath()?
Comment 5 Tomasz Morawski 2011-05-07 10:16:24 PDT
Thank you for your comments.

> codding style: (const char *settings_db_path)
Could you tell me what is wrong? I don't see what I have done wrong. Thare are many parameters name in this style in our headers. 

> > Source/WebKit/efl/ewk/ewk_main.cpp:197
> > +    if (!settings_db_path) {
> 
> Since you are creating the temp directory and returning from main() if temp directory creation fails, then it seems that all the code inside this if is dead code. Is it?
> Would not be better to make the decision about which directory to use in main and make parameter settings_db_path obligatory?
This is good idea but I have decided to not to make revolution in the code. But with pleasure I will do it. :) 
 
> > Source/WebKit/efl/ewk/ewk_main.cpp:201
> > +        // check home directory first
> 
> codding style: // Check home directory first.
> 
> > Source/WebKit/efl/ewk/ewk_main.cpp:203
> > +            // Exit now - otherwise you may have some crash later
> 
> codding style: missing period at the end of comment.
This is an old code... anyways what is wrong? Only missing dot at the end of comment?
Comment 6 Luiz Agostini 2011-05-10 10:24:44 PDT
(In reply to comment #5)
> Thank you for your comments.
> 
> > codding style: (const char *settings_db_path)
> Could you tell me what is wrong? I don't see what I have done wrong. Thare are many parameters name in this style in our headers. 

It is just about the * that should be at the type side. it should be char* instead of char *.
And you should avoid underlines as well.

> 
> > > Source/WebKit/efl/ewk/ewk_main.cpp:197
> > > +    if (!settings_db_path) {
> > 
> > Since you are creating the temp directory and returning from main() if temp directory creation fails, then it seems that all the code inside this if is dead code. Is it?
> > Would not be better to make the decision about which directory to use in main and make parameter settings_db_path obligatory?
> This is good idea but I have decided to not to make revolution in the code. But with pleasure I will do it. :) 

If it is about leaving dead code then I think that you should.

> 
> > > Source/WebKit/efl/ewk/ewk_main.cpp:201
> > > +        // check home directory first
> > 
> > codding style: // Check home directory first.
> > 
> > > Source/WebKit/efl/ewk/ewk_main.cpp:203
> > > +            // Exit now - otherwise you may have some crash later
> > 
> > codding style: missing period at the end of comment.
> This is an old code... anyways what is wrong? Only missing dot at the end of comment?

Comments should start with a capital letter and end with a period.
Comment 7 Tomasz Morawski 2011-05-11 00:28:28 PDT
Created attachment 93081 [details]
Patch 3
Comment 8 Tomasz Morawski 2011-05-11 00:30:08 PDT
(In reply to comment #6)
Thank you for your review. Could you lookat my new patch and check if it meets your needs?
Comment 9 Raphael Kubo da Costa (:rakuco) 2011-05-11 10:19:56 PDT
Could you explain why you added the stat()/S_ISDIR()/access() calls? WebCore::makeAllDirectories() already performs some access() calls besides calling mkdir() itself, so if you really want to ensure more information about the created path, IMO the changes should go there, not here.
Comment 10 Tomasz Morawski 2011-05-11 12:15:32 PDT
(In reply to comment #9)
> Could you explain why you added the stat()/S_ISDIR()/access() calls? WebCore::makeAllDirectories() already performs some access() calls besides calling mkdir() itself, so if you really want to ensure more information about the created path, IMO the changes should go there, not here.

If you give a path that point to a directory that already exist (even if the proces doesn't have rights to read or write to it) or to a file. The makeAllDirectory will return true. What is good because the path exist. No directory is needed to create.  So, additional checking is needed in our code to test if given path is a directory and if the proces have rights to write and read.
Comment 11 Raphael Kubo da Costa (:rakuco) 2011-05-11 13:24:10 PDT
IMO it makes sense to at least check if the path is already a directory in WebCore itself. As for the permission part, if you decide to keep it in WebKit, you could use ecore_file_can_{read,exec,write}.
Comment 12 Tomasz Morawski 2011-05-11 23:26:30 PDT
(In reply to comment #11)
> IMO it makes sense to at least check if the path is already a directory in WebCore itself. 

Lets lookat the makeAllDirectories function:

  if (!access(fullPath.data(), F_OK))
        return true;

The access(fullPath.data(), F_OK) function, returns 0 if path already exist. So, I can check there if this is a directory path and if user have rights to it... if not return false insted of true. I may try to make a patch for makeAllDirectories that will do it. But I am not sure if it will be accepted. 
 
> As for the permission part, if you decide to keep it in WebKit, you could use ecore_file_can_{read,exec,write}.
OK, this is a good idea. Thank you for that. I suggest to keep it if patch for makeAllDirectories will be not accepted.
Comment 13 Lukasz Slachciak 2011-05-12 02:49:36 PDT
*** Bug 59238 has been marked as a duplicate of this bug. ***
Comment 14 Luiz Agostini 2011-05-17 13:21:51 PDT
Just based on the name makeAllDirectories it is not possible to conclude what should it return in case the path already existed and if it is or not a directory, but I would say that permissions are not related to makeAllDirectories. There is no documentation and it seems that different platform implementations differ a bit from each other, but none of the ones I've seen are checking permissions.

This patch just considers that makeAllDirectories(path) will not return false if path already is a directory.

I like the patch as it is.
Comment 15 Kenneth Rohde Christiansen 2011-05-17 13:25:42 PDT
(In reply to comment #14)
> Just based on the name makeAllDirectories it is not possible to conclude what should it return in case the path already existed and if it is or not a directory, but I would say that permissions are not related to makeAllDirectories. There is no documentation and it seems that different platform implementations differ a bit from each other, but none of the ones I've seen are checking permissions.
> 
> This patch just considers that makeAllDirectories(path) will not return false if path already is a directory.
> 
> I like the patch as it is.

I looked at the patch and it is definitely an improvement. I think the above should be considered and can easily be fixed/improved in another patch. Thanks Luiz
Comment 16 Kenneth Rohde Christiansen 2011-05-17 13:27:08 PDT
Comment on attachment 93081 [details]
Patch 3

View in context: https://bugs.webkit.org/attachment.cgi?id=93081&action=review

> Tools/EWebLauncher/main.c:880
> -    ecore_file_mkpath(path);
> -    ewk_settings_icon_database_path_set(path);
> -    ewk_settings_web_database_path_set(path);
> +
> +    if (!ewk_init(path))

I think this is really API related so I would like Lucas input on it
Comment 17 Lucas De Marchi 2011-05-17 14:21:55 PDT
Comment on attachment 93081 [details]
Patch 3

View in context: https://bugs.webkit.org/attachment.cgi?id=93081&action=review

For the reason pointed above, my informal r-

>> Tools/EWebLauncher/main.c:880
>> +    if (!ewk_init(path))
> 
> I think this is really API related so I would like Lucas input on it

This is not how EFL works. There's no EFL lib with arguments in *_init() functions because you have to do only the bare minimum to initialize the lib. If you feel like you need an argument in init, you better split that functionality to another function that you call later.

In this case, IMO an acceptable patch would be not to set the cache/database/icon directory until the application (EWebLauncher) explicitly tells webkit to do so.
Comment 18 Kenneth Rohde Christiansen 2011-05-17 14:25:52 PDT
Comment on attachment 93081 [details]
Patch 3

r- for above reasons
Comment 19 Ryuan Choi 2011-11-03 18:32:26 PDT
Close this bug.
I agree with Lucas's opinion and there are no comment for a long time.