3 Replies Latest reply on Sep 9, 2010 4:07 PM by areohbee

    Unable to read metadata during the process or Slow?

    Allen Gambrell Level 1

      I am trying to write metadata to hundreds of files at a time. I need to me able to write and read back the updated metadata in the same process.Say like add the last name to the photo title then append the first name to the title. Each piece of data is another operation that can be set to overwrite or append to a certain field.

       

      The problem is when I enclose the entire operation inside a withWriteAccessDo block. In this case if I overwrite that title field with the last name and thend in the next operation I try to append the first name. The problem is that it does not get the updated metadata in the title field, it returns the orginal value!

       

      I can fix it by putting the withWriteAccessDo block inside the operation for loop so during each operations it uses a new withWriteAccessDo block. This way the updated metadata can be read back for the append correctly. The problem with this meathod is that it takes a very long time! like hours! before in Lightroom 2 this whole operation would take place in under 30 seconds and now it takes and hour!

       

      So here is some pusdocode

       

      1 does not get old data correctly

      withWriteAccessDo

           For each operation

                if overwite

                     write data to field

                else if append

                     get current filed data

                     concat old data with data to be added

                     write new data

                end

           loop

      end withWriteAccessDo

       

      2 works but takes a long time

      For each operation

           withWriteAccessDo

                if overwite

                     write data to field

                else if append

                     get current filed data

                     concat old data with data to be added

                     write new data

                end

           end withWriteAccessDo

      loop

       

      Anything that I am doing wrong?

        • 1. Re: Unable to read metadata during the process or Slow?
          areohbee Level 5

          Lightrooom has been extensively reworked under the hood as far as catalog writes go.

           

          Before: writes just wrote.

          Now: All writes are accumulated in a transaction but are not committed (and hence not accessible) until exiting the with-write gate. And,

          complete undo info is saved for every write.

           

          So, what I do for effiiciency is either:

          1) Make "to-do" functions

          2) Save "to-do" info.

           

          Then, call all these "to-do" functions, or process all this saved "to-do" info in a single write-gate, or in a succession of dependent write-gates.

           

          Rob

          • 2. Re: Unable to read metadata during the process or Slow?
            Allen Gambrell Level 1

            Thanks,

             

            I reworked it so on each operation I build a list on changes for each field of a image then I write all the changes. This way I do not have to read any vaules for lightroom except for the original one, which is ok.

            • 3. Re: Unable to read metadata during the process or Slow?
              areohbee Level 5

              You're welcome Allen.

               

              Another consideration is what level of Undo to offer your plugin users. And unlike the name used in lr-function-context.with... functions, the name used in the catalog with-gates is not just for debug (i.e. it is used in the Undo Menu), so provide good names for the Undo operations for your users.

               

              ...In case you hadn't noticed yet... (I hadn't noticed for a fairly long while)

               

              Rob