0

I use Google chrome in my Linux operation system, I enter into "~/.config/google-chrome/Default" which is the default chrome config directory.

I move the original Bookmarks file into another place and create a new Bookmarks file here that is a hard link file to the moved original Bookmarks file.

But after I save a new bookmark, chrome delete the new Bookmarks file and create a new file.

I am confused that how chrome identify that the Bookmarks file is not the original file in the case that two files have identical file names.

2

I think you are reading more into Chrome's behavior than is warranted. In general, there is little reason to believe that software is actively malicious. You are also using hard links, which can have somewhat unintuitive behavior in edge cases.

Specifically here, a common way of making writes at least semi-atomic is to rewrite the contents of the file under a new name, and then move the new file into the old file's location.

As a step-by-step process, this can look like this:

  1. Generate a random file name that does not exist in the intended target directory
  2. Create that temporary file
  3. Write the data to the temporary file
  4. Rename the old file to a different name
  5. Rename the temporary file so that it has the same name as the original file
  6. Delete the old file

This process ensures that at all times, at least one valid copy of the data exists on disk. Hence, even if the program crashes half-way through, it's easy to recover to a known valid state.

However, as a consequence, step #4 breaks the hard link, and step #5 puts something else under the same name.

If you simply want to be able to access your bookmarks file under a different name, I suggest simply making that other name a symbolic link to the bookmarks file.

  • I think you misunderstand my intention.what I really want to get is that make chrome use another file not the file in the default config directory to save bookmark data.And I think using a hardlink file may be a way to obtain that. – user2351281 Oct 30 '15 at 9:03
  • @user2351281 The title, which is meant to be a short summary of your question, asks "why is a created own Bookmarks file deleted by chrome". In what way do you feel my answer doesn't address that question? Note the placeholder text in the title field of the ask question page: "What's your computer software or computer hardware question? Be specific." – a CVn Oct 30 '15 at 9:28
  • I read your answer again and I find that you actually solve my question.Apologize for my unwisdom. By the way,I do not think using symbolic link can solve my problem.please see my next comment. – user2351281 Oct 31 '15 at 7:12
  • I have two Linux OSs and two chrome browsers in them,what I want to do is sync their bookmark files not using chrome's own sync utility.And I think out using DropBox-like product to do that. If in the Linux OS one,I create a symbolic link file in DropBox work directory which points to the chrome's bookmark file.I am not sure DropBox could in Linux OS two treat the mentioned file as a symbolic link file too.Even if it is so,what if the two chrome's bookmark files reside in different paths in the two Linux OSs? – user2351281 Oct 31 '15 at 7:12
  • @user2351281 If that's your problem, then you should post a question about that problem. Think of the Stack Exchange network not primarily as a discussion-forum style back-and-forth, but rather as a way to submit a question once and then get answers to that question back (assuming that the question is well-written, clear enough, on-topic for the particular site, etc.). You are now asking a very different question, which seems to get to the bottom of your problem. I would say both questions have lasting value, but since they are so different, they should be asked as separate questions. – a CVn Oct 31 '15 at 12:40

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.